
<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>pymatgen.io.vasp.sets &#8212; pymatgen 2020.7.3 documentation</title>
    <link rel="stylesheet" href="../../../../_static/basic.css" type="text/css" />
    <link rel="stylesheet" href="../../../../_static/pygments.css" type="text/css" />
    <script id="documentation_options" data-url_root="../../../../" src="../../../../_static/documentation_options.js"></script>
    <script src="../../../../_static/jquery.js"></script>
    <script src="../../../../_static/underscore.js"></script>
    <script src="../../../../_static/doctools.js"></script>
    <script src="../../../../_static/language_data.js"></script>
    <script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
    <link rel="index" title="Index" href="../../../../genindex.html" />
    <link rel="search" title="Search" href="../../../../search.html" />
 
<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-33990148-1']);
  _gaq.push(['_trackPageview']);
</script>

  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../../../index.html">pymatgen 2020.7.3 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../../../index.html" >Module code</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="../../../pymatgen.html" accesskey="U">pymatgen</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">pymatgen.io.vasp.sets</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
          <div class="body" role="main">
            
  <h1>Source code for pymatgen.io.vasp.sets</h1><div class="highlight"><pre>
<span></span><span class="c1"># coding: utf-8</span>
<span class="c1"># Copyright (c) Pymatgen Development Team.</span>
<span class="c1"># Distributed under the terms of the MIT License.</span>

<span class="sd">&quot;&quot;&quot;</span>
<span class="sd">This module defines the VaspInputSet abstract base class and a concrete</span>
<span class="sd">implementation for the parameters developed and tested by the core team</span>
<span class="sd">of pymatgen, including the Materials Virtual Lab, Materials Project and the MIT</span>
<span class="sd">high throughput project.  The basic concept behind an input set is to specify</span>
<span class="sd">a scheme to generate a consistent set of VASP inputs from a structure</span>
<span class="sd">without further user intervention. This ensures comparability across</span>
<span class="sd">runs.</span>

<span class="sd">Read the following carefully before implementing new input sets:</span>

<span class="sd">1. 99% of what needs to be done can be done by specifying user_incar_settings</span>
<span class="sd">   to override some of the defaults of various input sets. Unless there is an</span>
<span class="sd">   extremely good reason to add a new set, DO NOT add one. E.g., if you want</span>
<span class="sd">   to turn the hubbard U off, just set &quot;LDAU&quot;: False as a user_incar_setting.</span>
<span class="sd">2. All derivative input sets should inherit from one of the usual MPRelaxSet or</span>
<span class="sd">   MITRelaxSet, and proper superclass delegation should be used where possible.</span>
<span class="sd">   In particular, you are not supposed to implement your own as_dict or</span>
<span class="sd">   from_dict for derivative sets unless you know what you are doing.</span>
<span class="sd">   Improper overriding the as_dict and from_dict protocols is the major</span>
<span class="sd">   cause of implementation headaches. If you need an example, look at how the</span>
<span class="sd">   MPStaticSet or MPNonSCFSets are constructed.</span>

<span class="sd">The above are recommendations. The following are UNBREAKABLE rules:</span>

<span class="sd">1. All input sets must take in a structure or list of structures as the first</span>
<span class="sd">   argument.</span>
<span class="sd">2. user_incar_settings, user_kpoints_settings and user_&lt;whatever&gt;_settings are</span>
<span class="sd">   ABSOLUTE. Any new sets you implement must obey this. If a user wants to</span>
<span class="sd">   override your settings, you assume he knows what he is doing. Do not</span>
<span class="sd">   magically override user supplied settings. You can issue a warning if you</span>
<span class="sd">   think the user is wrong.</span>
<span class="sd">3. All input sets must save all supplied args and kwargs as instance variables.</span>
<span class="sd">   E.g., self.my_arg = my_arg and self.kwargs = kwargs in the __init__. This</span>
<span class="sd">   ensures the as_dict and from_dict work correctly.</span>
<span class="sd">&quot;&quot;&quot;</span>

<span class="kn">import</span> <span class="nn">abc</span>
<span class="kn">import</span> <span class="nn">glob</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">re</span>
<span class="kn">import</span> <span class="nn">shutil</span>
<span class="kn">import</span> <span class="nn">warnings</span>
<span class="kn">from</span> <span class="nn">copy</span> <span class="kn">import</span> <span class="n">deepcopy</span>
<span class="kn">from</span> <span class="nn">itertools</span> <span class="kn">import</span> <span class="n">chain</span>
<span class="kn">from</span> <span class="nn">pathlib</span> <span class="kn">import</span> <span class="n">Path</span>
<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">List</span><span class="p">,</span> <span class="n">Union</span><span class="p">,</span> <span class="n">Optional</span>
<span class="kn">from</span> <span class="nn">zipfile</span> <span class="kn">import</span> <span class="n">ZipFile</span>

<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="kn">from</span> <span class="nn">monty.dev</span> <span class="kn">import</span> <span class="n">deprecated</span>
<span class="kn">from</span> <span class="nn">monty.io</span> <span class="kn">import</span> <span class="n">zopen</span>
<span class="kn">from</span> <span class="nn">monty.json</span> <span class="kn">import</span> <span class="n">MSONable</span>
<span class="kn">from</span> <span class="nn">monty.serialization</span> <span class="kn">import</span> <span class="n">loadfn</span>

<span class="kn">from</span> <span class="nn">pymatgen.analysis.structure_matcher</span> <span class="kn">import</span> <span class="n">StructureMatcher</span>
<span class="kn">from</span> <span class="nn">pymatgen.core.periodic_table</span> <span class="kn">import</span> <span class="n">Specie</span><span class="p">,</span> <span class="n">Element</span>
<span class="kn">from</span> <span class="nn">pymatgen.core.sites</span> <span class="kn">import</span> <span class="n">PeriodicSite</span>
<span class="kn">from</span> <span class="nn">pymatgen.core.structure</span> <span class="kn">import</span> <span class="n">Structure</span>
<span class="kn">from</span> <span class="nn">pymatgen.io.lobster</span> <span class="kn">import</span> <span class="n">Lobsterin</span>
<span class="kn">from</span> <span class="nn">pymatgen.io.vasp.inputs</span> <span class="kn">import</span> <span class="n">Incar</span><span class="p">,</span> <span class="n">Poscar</span><span class="p">,</span> <span class="n">Potcar</span><span class="p">,</span> <span class="n">Kpoints</span><span class="p">,</span> <span class="n">VaspInput</span>
<span class="kn">from</span> <span class="nn">pymatgen.io.vasp.outputs</span> <span class="kn">import</span> <span class="n">Vasprun</span><span class="p">,</span> <span class="n">Outcar</span>
<span class="kn">from</span> <span class="nn">pymatgen.symmetry.analyzer</span> <span class="kn">import</span> <span class="n">SpacegroupAnalyzer</span>
<span class="kn">from</span> <span class="nn">pymatgen.symmetry.bandstructure</span> <span class="kn">import</span> <span class="n">HighSymmKpath</span>

<span class="n">__author__</span> <span class="o">=</span> <span class="p">(</span>
    <span class="s2">&quot;Shyue Ping Ong, Wei Chen, Will Richards, Geoffroy Hautier, &quot;</span> <span class="s2">&quot;Anubhav Jain&quot;</span>
<span class="p">)</span>
<span class="n">__copyright__</span> <span class="o">=</span> <span class="s2">&quot;Copyright 2011, The Materials Project&quot;</span>
<span class="n">__version__</span> <span class="o">=</span> <span class="s2">&quot;1.0&quot;</span>
<span class="n">__maintainer__</span> <span class="o">=</span> <span class="s2">&quot;Shyue Ping Ong&quot;</span>
<span class="n">__email__</span> <span class="o">=</span> <span class="s2">&quot;shyuep@gmail.com&quot;</span>
<span class="n">__date__</span> <span class="o">=</span> <span class="s2">&quot;May 28 2016&quot;</span>

<span class="n">MODULE_DIR</span> <span class="o">=</span> <span class="n">Path</span><span class="p">(</span><span class="vm">__file__</span><span class="p">)</span><span class="o">.</span><span class="n">resolve</span><span class="p">()</span><span class="o">.</span><span class="n">parent</span>


<div class="viewcode-block" id="VaspInputSet"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.VaspInputSet">[docs]</a><span class="k">class</span> <span class="nc">VaspInputSet</span><span class="p">(</span><span class="n">MSONable</span><span class="p">,</span> <span class="n">metaclass</span><span class="o">=</span><span class="n">abc</span><span class="o">.</span><span class="n">ABCMeta</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Base class representing a set of Vasp input parameters with a structure</span>
<span class="sd">    supplied as init parameters. Typically, you should not inherit from this</span>
<span class="sd">    class. Start from DictSet or MPRelaxSet or MITRelaxSet.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="nd">@property</span>
    <span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
    <span class="k">def</span> <span class="nf">incar</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Incar object&quot;&quot;&quot;</span>
        <span class="k">pass</span>

    <span class="nd">@property</span>
    <span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
    <span class="k">def</span> <span class="nf">kpoints</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Kpoints object&quot;&quot;&quot;</span>
        <span class="k">pass</span>

    <span class="nd">@property</span>
    <span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
    <span class="k">def</span> <span class="nf">poscar</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Poscar object&quot;&quot;&quot;</span>
        <span class="k">pass</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">potcar_symbols</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        List of POTCAR symbols.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">elements</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">poscar</span><span class="o">.</span><span class="n">site_symbols</span>
        <span class="n">potcar_symbols</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">settings</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_config_dict</span><span class="p">[</span><span class="s2">&quot;POTCAR&quot;</span><span class="p">]</span>

        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">settings</span><span class="p">[</span><span class="n">elements</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]],</span> <span class="nb">dict</span><span class="p">):</span>
            <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">elements</span><span class="p">:</span>
                <span class="n">potcar_symbols</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">settings</span><span class="p">[</span><span class="n">el</span><span class="p">][</span><span class="s2">&quot;symbol&quot;</span><span class="p">]</span> <span class="k">if</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">settings</span> <span class="k">else</span> <span class="n">el</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">elements</span><span class="p">:</span>
                <span class="n">potcar_symbols</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">settings</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">el</span><span class="p">,</span> <span class="n">el</span><span class="p">))</span>

        <span class="k">return</span> <span class="n">potcar_symbols</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">potcar</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Potcar object.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">potcar</span> <span class="o">=</span> <span class="n">Potcar</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">potcar_symbols</span><span class="p">,</span> <span class="n">functional</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">potcar_functional</span><span class="p">)</span>

        <span class="c1"># warn if the selected POTCARs do not correspond to the chosen</span>
        <span class="c1"># potcar_functional</span>
        <span class="k">for</span> <span class="n">psingle</span> <span class="ow">in</span> <span class="n">potcar</span><span class="p">:</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">potcar_functional</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">psingle</span><span class="o">.</span><span class="n">identify_potcar</span><span class="p">()[</span><span class="mi">0</span><span class="p">]:</span>
                <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span>
                    <span class="s2">&quot;POTCAR data with symbol </span><span class="si">{}</span><span class="s2"> is not known by pymatgen to</span><span class="se">\</span>
<span class="s2">                    correspond with the selected potcar_functional </span><span class="si">{}</span><span class="s2">. This POTCAR</span><span class="se">\</span>
<span class="s2">                    is known to correspond with functionals </span><span class="si">{}</span><span class="s2">. Please verify that</span><span class="se">\</span>
<span class="s2">                    you are using the right POTCARs!&quot;</span>
                        <span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">psingle</span><span class="o">.</span><span class="n">symbol</span><span class="p">,</span>
                                <span class="bp">self</span><span class="o">.</span><span class="n">potcar_functional</span><span class="p">,</span>
                                <span class="n">psingle</span><span class="o">.</span><span class="n">identify_potcar</span><span class="p">(</span><span class="n">mode</span><span class="o">=</span><span class="s1">&#39;data&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]),</span>
                    <span class="n">BadInputSetWarning</span><span class="p">,</span>
                <span class="p">)</span>

        <span class="k">return</span> <span class="n">potcar</span>

    <span class="nd">@property</span>  <span class="c1"># type: ignore</span>
    <span class="nd">@deprecated</span><span class="p">(</span><span class="n">message</span><span class="o">=</span><span class="s2">&quot;Use the get_vasp_input() method instead.&quot;</span><span class="p">)</span>
    <span class="k">def</span> <span class="nf">all_input</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Returns all input files as a dict of {filename: vasp object}</span>

<span class="sd">        Returns:</span>
<span class="sd">            dict of {filename: object}, e.g., {&#39;INCAR&#39;: Incar object, ...}</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="p">{</span>
            <span class="s2">&quot;INCAR&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">incar</span><span class="p">,</span>
            <span class="s2">&quot;KPOINTS&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">kpoints</span><span class="p">,</span>
            <span class="s2">&quot;POSCAR&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">poscar</span><span class="p">,</span>
            <span class="s2">&quot;POTCAR&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">potcar</span><span class="p">,</span>
        <span class="p">}</span>

<div class="viewcode-block" id="VaspInputSet.get_vasp_input"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.VaspInputSet.get_vasp_input">[docs]</a>    <span class="k">def</span> <span class="nf">get_vasp_input</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">VaspInput</span><span class="p">:</span>
        <span class="sd">&quot;&quot;&quot;</span>

<span class="sd">        Returns:</span>
<span class="sd">            VaspInput</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="n">VaspInput</span><span class="p">(</span>
            <span class="n">incar</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">incar</span><span class="p">,</span>
            <span class="n">kpoints</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">kpoints</span><span class="p">,</span>
            <span class="n">poscar</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">poscar</span><span class="p">,</span>
            <span class="n">potcar</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">potcar</span><span class="p">,</span>
        <span class="p">)</span></div>

<div class="viewcode-block" id="VaspInputSet.write_input"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.VaspInputSet.write_input">[docs]</a>    <span class="k">def</span> <span class="nf">write_input</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">output_dir</span><span class="p">,</span> <span class="n">make_dir_if_not_present</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">include_cif</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
                    <span class="n">potcar_spec</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">zip_output</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Writes a set of VASP input to a directory.</span>

<span class="sd">        Args:</span>
<span class="sd">            output_dir (str): Directory to output the VASP input files</span>
<span class="sd">            make_dir_if_not_present (bool): Set to True if you want the</span>
<span class="sd">                directory (and the whole path) to be created if it is not</span>
<span class="sd">                present.</span>
<span class="sd">            include_cif (bool): Whether to write a CIF file in the output</span>
<span class="sd">                directory for easier opening by VESTA.</span>
<span class="sd">            potcar_spec (bool): Instead of writing the POTCAR, write a &quot;POTCAR.spec&quot;.</span>
<span class="sd">                This is intended to help sharing an input set with people who might</span>
<span class="sd">                not have a license to specific Potcar files. Given a &quot;POTCAR.spec&quot;,</span>
<span class="sd">                the specific POTCAR file can be re-generated using pymatgen with the</span>
<span class="sd">                &quot;generate_potcar&quot; function in the pymatgen CLI.</span>
<span class="sd">            zip_output (bool): If True, output will be zipped into a file with the</span>
<span class="sd">                same name as the InputSet (e.g., MPStaticSet.zip)</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="n">potcar_spec</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">make_dir_if_not_present</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">output_dir</span><span class="p">):</span>
                <span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span><span class="n">output_dir</span><span class="p">)</span>

            <span class="k">with</span> <span class="n">zopen</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">output_dir</span><span class="p">,</span> <span class="s2">&quot;POTCAR.spec&quot;</span><span class="p">),</span> <span class="s2">&quot;wt&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
                <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">potcar_symbols</span><span class="p">))</span>

            <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="p">{</span><span class="s2">&quot;INCAR&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">incar</span><span class="p">,</span>
                         <span class="s2">&quot;POSCAR&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">poscar</span><span class="p">,</span>
                         <span class="s2">&quot;KPOINTS&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">kpoints</span>
                         <span class="p">}</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
                <span class="k">if</span> <span class="n">v</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
                    <span class="k">with</span> <span class="n">zopen</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">output_dir</span><span class="p">,</span> <span class="n">k</span><span class="p">),</span> <span class="s2">&quot;wt&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
                        <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">v</span><span class="o">.</span><span class="fm">__str__</span><span class="p">())</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">vinput</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_vasp_input</span><span class="p">()</span>
            <span class="n">vinput</span><span class="o">.</span><span class="n">write_input</span><span class="p">(</span><span class="n">output_dir</span><span class="p">,</span> <span class="n">make_dir_if_not_present</span><span class="o">=</span><span class="n">make_dir_if_not_present</span><span class="p">)</span>

        <span class="n">cifname</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span>
        <span class="k">if</span> <span class="n">include_cif</span><span class="p">:</span>
            <span class="n">s</span> <span class="o">=</span> <span class="n">vinput</span><span class="p">[</span><span class="s2">&quot;POSCAR&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">structure</span>
            <span class="n">cifname</span> <span class="o">=</span> <span class="n">Path</span><span class="p">(</span><span class="n">output_dir</span><span class="p">)</span> <span class="o">/</span> <span class="p">(</span><span class="s2">&quot;</span><span class="si">%s</span><span class="s2">.cif&quot;</span> <span class="o">%</span> <span class="n">re</span><span class="o">.</span><span class="n">sub</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;\s&quot;</span><span class="p">,</span> <span class="s2">&quot;&quot;</span><span class="p">,</span> <span class="n">s</span><span class="o">.</span><span class="n">formula</span><span class="p">))</span>
            <span class="n">s</span><span class="o">.</span><span class="n">to</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="n">cifname</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">zip_output</span><span class="p">:</span>
            <span class="n">filename</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">+</span> <span class="s2">&quot;.zip&quot;</span>
            <span class="k">with</span> <span class="n">ZipFile</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="s2">&quot;w&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="nb">zip</span><span class="p">:</span>
                <span class="k">for</span> <span class="n">file</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;INCAR&quot;</span><span class="p">,</span> <span class="s2">&quot;POSCAR&quot;</span><span class="p">,</span> <span class="s2">&quot;KPOINTS&quot;</span><span class="p">,</span> <span class="s2">&quot;POTCAR&quot;</span><span class="p">,</span> <span class="s2">&quot;POTCAR.spec&quot;</span><span class="p">,</span> <span class="n">cifname</span><span class="p">]:</span>
                    <span class="k">try</span><span class="p">:</span>
                        <span class="nb">zip</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">file</span><span class="p">)</span>
                        <span class="n">os</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">file</span><span class="p">)</span>
                    <span class="k">except</span> <span class="ne">FileNotFoundError</span><span class="p">:</span>
                        <span class="k">pass</span></div>

<div class="viewcode-block" id="VaspInputSet.as_dict"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.VaspInputSet.as_dict">[docs]</a>    <span class="k">def</span> <span class="nf">as_dict</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">verbosity</span><span class="o">=</span><span class="mi">2</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            verbosity: Verbosity for generated dict. If 1, structure is</span>
<span class="sd">            excluded.</span>

<span class="sd">        Returns:</span>
<span class="sd">            MSONable dict</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">d</span> <span class="o">=</span> <span class="n">MSONable</span><span class="o">.</span><span class="n">as_dict</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">verbosity</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
            <span class="n">d</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">&quot;structure&quot;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">d</span></div></div>


<span class="k">def</span> <span class="nf">_load_yaml_config</span><span class="p">(</span><span class="n">fname</span><span class="p">):</span>
    <span class="n">config</span> <span class="o">=</span> <span class="n">loadfn</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">MODULE_DIR</span> <span class="o">/</span> <span class="p">(</span><span class="s2">&quot;</span><span class="si">%s</span><span class="s2">.yaml&quot;</span> <span class="o">%</span> <span class="n">fname</span><span class="p">)))</span>
    <span class="k">if</span> <span class="s2">&quot;PARENT&quot;</span> <span class="ow">in</span> <span class="n">config</span><span class="p">:</span>
        <span class="n">parent_config</span> <span class="o">=</span> <span class="n">_load_yaml_config</span><span class="p">(</span><span class="n">config</span><span class="p">[</span><span class="s2">&quot;PARENT&quot;</span><span class="p">])</span>
        <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">parent_config</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
            <span class="k">if</span> <span class="n">k</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">config</span><span class="p">:</span>
                <span class="n">config</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="n">v</span>
            <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span>
                <span class="n">v_new</span> <span class="o">=</span> <span class="n">config</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="p">{})</span>
                <span class="n">v_new</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">v</span><span class="p">)</span>
                <span class="n">config</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="n">v_new</span>
    <span class="k">return</span> <span class="n">config</span>


<div class="viewcode-block" id="DictSet"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.DictSet">[docs]</a><span class="k">class</span> <span class="nc">DictSet</span><span class="p">(</span><span class="n">VaspInputSet</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Concrete implementation of VaspInputSet that is initialized from a dict</span>
<span class="sd">    settings. This allows arbitrary settings to be input. In general,</span>
<span class="sd">    this is rarely used directly unless there is a source of settings in yaml</span>
<span class="sd">    format (e.g., from a REST interface). It is typically used by other</span>
<span class="sd">    VaspInputSets for initialization.</span>

<span class="sd">    Special consideration should be paid to the way the MAGMOM initialization</span>
<span class="sd">    for the INCAR is done. The initialization differs depending on the type of</span>
<span class="sd">    structure and the configuration settings. The order in which the magmom is</span>
<span class="sd">    determined is as follows:</span>

<span class="sd">    1. If the site itself has a magmom setting, that is used.</span>
<span class="sd">    2. If the species on the site has a spin setting, that is used.</span>
<span class="sd">    3. If the species itself has a particular setting in the config file, that</span>
<span class="sd">       is used, e.g., Mn3+ may have a different magmom than Mn4+.</span>
<span class="sd">    4. Lastly, the element symbol itself is checked in the config file. If</span>
<span class="sd">       there are no settings, VASP&#39;s default of 0.6 is used.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span>
            <span class="bp">self</span><span class="p">,</span>
            <span class="n">structure</span><span class="p">,</span>
            <span class="n">config_dict</span><span class="p">,</span>
            <span class="n">files_to_transfer</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
            <span class="n">user_incar_settings</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
            <span class="n">user_kpoints_settings</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
            <span class="n">user_potcar_settings</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
            <span class="n">constrain_total_magmom</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
            <span class="n">sort_structure</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
            <span class="n">potcar_functional</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
            <span class="n">user_potcar_functional</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
            <span class="n">force_gamma</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
            <span class="n">reduce_structure</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
            <span class="n">vdw</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
            <span class="n">use_structure_charge</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
            <span class="n">standardize</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
            <span class="n">sym_prec</span><span class="o">=</span><span class="mf">0.1</span><span class="p">,</span>
            <span class="n">international_monoclinic</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
    <span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            structure (Structure): The Structure to create inputs for.</span>
<span class="sd">            config_dict (dict): The config dictionary to use.</span>
<span class="sd">            files_to_transfer (dict): A dictionary of {filename: filepath}. This</span>
<span class="sd">                allows the transfer of files from a previous calculation.</span>
<span class="sd">            user_incar_settings (dict): User INCAR settings. This allows a user</span>
<span class="sd">                to override INCAR settings, e.g., setting a different MAGMOM for</span>
<span class="sd">                various elements or species. Note that in the new scheme,</span>
<span class="sd">                ediff_per_atom and hubbard_u are no longer args. Instead, the</span>
<span class="sd">                config_dict supports EDIFF_PER_ATOM and EDIFF keys. The former</span>
<span class="sd">                scales with # of atoms, the latter does not. If both are</span>
<span class="sd">                present, EDIFF is preferred. To force such settings, just supply</span>
<span class="sd">                user_incar_settings={&quot;EDIFF&quot;: 1e-5, &quot;LDAU&quot;: False} for example.</span>
<span class="sd">                The keys &#39;LDAUU&#39;, &#39;LDAUJ&#39;, &#39;LDAUL&#39; are special cases since</span>
<span class="sd">                pymatgen defines different values depending on what anions are</span>
<span class="sd">                present in the structure, so these keys can be defined in one</span>
<span class="sd">                of two ways, e.g. either {&quot;LDAUU&quot;:{&quot;O&quot;:{&quot;Fe&quot;:5}}} to set LDAUU</span>
<span class="sd">                for Fe to 5 in an oxide, or {&quot;LDAUU&quot;:{&quot;Fe&quot;:5}} to set LDAUU to</span>
<span class="sd">                5 regardless of the input structure.</span>

<span class="sd">                If a None value is given, that key is unset. For example,</span>
<span class="sd">                {&quot;ENCUT&quot;: None} will remove ENCUT from the incar settings.</span>
<span class="sd">            user_kpoints_settings (dict or Kpoints): Allow user to override kpoints</span>
<span class="sd">                setting by supplying a dict E.g., {&quot;reciprocal_density&quot;: 1000}.</span>
<span class="sd">                User can also supply Kpoints object. Default is None.</span>
<span class="sd">            user_potcar_settings (dict: Allow user to override POTCARs. E.g.,</span>
<span class="sd">                {&quot;Gd&quot;: &quot;Gd_3&quot;}. This is generally not recommended. Default is None.</span>
<span class="sd">            constrain_total_magmom (bool): Whether to constrain the total magmom</span>
<span class="sd">                (NUPDOWN in INCAR) to be the sum of the expected MAGMOM for all</span>
<span class="sd">                species. Defaults to False.</span>
<span class="sd">            sort_structure (bool): Whether to sort the structure (using the</span>
<span class="sd">                default sort order of electronegativity) before generating input</span>
<span class="sd">                files. Defaults to True, the behavior you would want most of the</span>
<span class="sd">                time. This ensures that similar atomic species are grouped</span>
<span class="sd">                together.</span>
<span class="sd">            user_potcar_functional (str): Functional to use. Default (None) is to use</span>
<span class="sd">                the functional in the config dictionary. Valid values:</span>
<span class="sd">                &quot;PBE&quot;, &quot;PBE_52&quot;, &quot;PBE_54&quot;, &quot;LDA&quot;, &quot;LDA_52&quot;, &quot;LDA_54&quot;, &quot;PW91&quot;,</span>
<span class="sd">                &quot;LDA_US&quot;, &quot;PW91_US&quot;.</span>
<span class="sd">            force_gamma (bool): Force gamma centered kpoint generation. Default</span>
<span class="sd">                (False) is to use the Automatic Density kpoint scheme, which</span>
<span class="sd">                will use the Gamma centered generation scheme for hexagonal</span>
<span class="sd">                cells, and Monkhorst-Pack otherwise.</span>
<span class="sd">            reduce_structure (None/str): Before generating the input files,</span>
<span class="sd">                generate the reduced structure. Default (None), does not</span>
<span class="sd">                alter the structure. Valid values: None, &quot;niggli&quot;, &quot;LLL&quot;.</span>
<span class="sd">            vdw: Adds default parameters for van-der-Waals functionals supported</span>
<span class="sd">                by VASP to INCAR. Supported functionals are: DFT-D2, undamped</span>
<span class="sd">                DFT-D3, DFT-D3 with Becke-Jonson damping, Tkatchenko-Scheffler,</span>
<span class="sd">                Tkatchenko-Scheffler with iterative Hirshfeld partitioning,</span>
<span class="sd">                MBD@rSC, dDsC, Dion&#39;s vdW-DF, DF2, optPBE, optB88, optB86b and</span>
<span class="sd">                rVV10.</span>
<span class="sd">            use_structure_charge (bool): If set to True, then the public</span>
<span class="sd">                variable used for setting the overall charge of the</span>
<span class="sd">                structure (structure.charge) is used to set the NELECT</span>
<span class="sd">                variable in the INCAR</span>
<span class="sd">                Default is False (structure&#39;s overall charge is not used)</span>
<span class="sd">            standardize (float): Whether to standardize to a primitive standard</span>
<span class="sd">                cell. Defaults to False.</span>
<span class="sd">            sym_prec (float): Tolerance for symmetry finding.</span>
<span class="sd">            international_monoclinic (bool): Whether to use international convention</span>
<span class="sd">                (vs Curtarolo) for monoclinic. Defaults True.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="n">reduce_structure</span><span class="p">:</span>
            <span class="n">structure</span> <span class="o">=</span> <span class="n">structure</span><span class="o">.</span><span class="n">get_reduced_structure</span><span class="p">(</span><span class="n">reduce_structure</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">sort_structure</span><span class="p">:</span>
            <span class="n">structure</span> <span class="o">=</span> <span class="n">structure</span><span class="o">.</span><span class="n">get_sorted_structure</span><span class="p">()</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">_structure</span> <span class="o">=</span> <span class="n">structure</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_config_dict</span> <span class="o">=</span> <span class="n">deepcopy</span><span class="p">(</span><span class="n">config_dict</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">files_to_transfer</span> <span class="o">=</span> <span class="n">files_to_transfer</span> <span class="ow">or</span> <span class="p">{}</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">constrain_total_magmom</span> <span class="o">=</span> <span class="n">constrain_total_magmom</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">sort_structure</span> <span class="o">=</span> <span class="n">sort_structure</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">force_gamma</span> <span class="o">=</span> <span class="n">force_gamma</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">reduce_structure</span> <span class="o">=</span> <span class="n">reduce_structure</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">user_incar_settings</span> <span class="o">=</span> <span class="n">user_incar_settings</span> <span class="ow">or</span> <span class="p">{}</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">user_kpoints_settings</span> <span class="o">=</span> <span class="n">user_kpoints_settings</span> <span class="ow">or</span> <span class="p">{}</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">user_potcar_settings</span> <span class="o">=</span> <span class="n">user_potcar_settings</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">vdw</span> <span class="o">=</span> <span class="n">vdw</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="k">if</span> <span class="n">vdw</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> <span class="kc">None</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">use_structure_charge</span> <span class="o">=</span> <span class="n">use_structure_charge</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">standardize</span> <span class="o">=</span> <span class="n">standardize</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">sym_prec</span> <span class="o">=</span> <span class="n">sym_prec</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">international_monoclinic</span> <span class="o">=</span> <span class="n">international_monoclinic</span>

        <span class="k">if</span> <span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">user_incar_settings</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;KSPACING&quot;</span><span class="p">)</span>
                <span class="ow">and</span> <span class="n">user_kpoints_settings</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span>
        <span class="p">):</span>
            <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span>
                <span class="s2">&quot;You have specified KSPACING and also supplied kpoints &quot;</span>
                <span class="s2">&quot;settings. KSPACING only has effect when there is no &quot;</span>
                <span class="s2">&quot;KPOINTS file. Since both settings were given, pymatgen&quot;</span>
                <span class="s2">&quot;will generate a KPOINTS file and ignore KSPACING.&quot;</span>
                <span class="s2">&quot;Remove the `user_kpoints_settings` argument to enable KSPACING.&quot;</span><span class="p">,</span>
                <span class="n">BadInputSetWarning</span><span class="p">,</span>
            <span class="p">)</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">vdw</span><span class="p">:</span>
            <span class="n">vdw_par</span> <span class="o">=</span> <span class="n">loadfn</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">MODULE_DIR</span> <span class="o">/</span> <span class="s2">&quot;vdW_parameters.yaml&quot;</span><span class="p">))</span>
            <span class="k">try</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">_config_dict</span><span class="p">[</span><span class="s2">&quot;INCAR&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">vdw_par</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">vdw</span><span class="p">])</span>
            <span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span>
                <span class="k">raise</span> <span class="ne">KeyError</span><span class="p">(</span>
                    <span class="s2">&quot;Invalid or unsupported van-der-Waals &quot;</span>
                    <span class="s2">&quot;functional. Supported functionals are &quot;</span>
                    <span class="s2">&quot;</span><span class="si">%s</span><span class="s2">.&quot;</span> <span class="o">%</span> <span class="n">vdw_par</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span>
                <span class="p">)</span>
        <span class="c1"># read the POTCAR_FUNCTIONAL from the .yaml</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">potcar_functional</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_config_dict</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;POTCAR_FUNCTIONAL&quot;</span><span class="p">,</span> <span class="s2">&quot;PBE&quot;</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">potcar_functional</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="ow">and</span> <span class="n">user_potcar_functional</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;Received both &#39;potcar_functional&#39; and &quot;</span>
                <span class="s2">&quot;&#39;user_potcar_functional arguments. &#39;potcar_functional &quot;</span>
                <span class="s2">&quot;is deprecated.&quot;</span>
            <span class="p">)</span>
        <span class="k">if</span> <span class="n">potcar_functional</span><span class="p">:</span>
            <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span>
                <span class="s2">&quot;&#39;potcar_functional&#39; argument is deprecated. Use &quot;</span>
                <span class="s2">&quot;&#39;user_potcar_functional&#39; instead.&quot;</span><span class="p">,</span>
                <span class="ne">DeprecationWarning</span><span class="p">,</span>
            <span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">potcar_functional</span> <span class="o">=</span> <span class="n">potcar_functional</span>
        <span class="k">elif</span> <span class="n">user_potcar_functional</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">potcar_functional</span> <span class="o">=</span> <span class="n">user_potcar_functional</span>

        <span class="c1"># warn if a user is overriding POTCAR_FUNCTIONAL</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">potcar_functional</span> <span class="o">!=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_config_dict</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;POTCAR_FUNCTIONAL&quot;</span><span class="p">):</span>
            <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span>
                <span class="s2">&quot;Overriding the POTCAR functional is generally not recommended &quot;</span>
                <span class="s2">&quot; as it significantly affect the results of calculations and &quot;</span>
                <span class="s2">&quot;compatibility with other calculations done with the same &quot;</span>
                <span class="s2">&quot;input set. Note that some POTCAR symbols specified in &quot;</span>
                <span class="s2">&quot;the configuration file may not be available in the selected &quot;</span>
                <span class="s2">&quot;functional.&quot;</span><span class="p">,</span>
                <span class="n">BadInputSetWarning</span><span class="p">,</span>
            <span class="p">)</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">user_potcar_settings</span><span class="p">:</span>
            <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span>
                <span class="s2">&quot;Overriding POTCARs is generally not recommended as it &quot;</span>
                <span class="s2">&quot;significantly affect the results of calculations and &quot;</span>
                <span class="s2">&quot;compatibility with other calculations done with the same &quot;</span>
                <span class="s2">&quot;input set. In many instances, it is better to write a &quot;</span>
                <span class="s2">&quot;subclass of a desired input set and override the POTCAR in &quot;</span>
                <span class="s2">&quot;the subclass to be explicit on the differences.&quot;</span><span class="p">,</span>
                <span class="n">BadInputSetWarning</span><span class="p">,</span>
            <span class="p">)</span>
            <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">user_potcar_settings</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">_config_dict</span><span class="p">[</span><span class="s2">&quot;POTCAR&quot;</span><span class="p">][</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="n">v</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">structure</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Structure</span><span class="p">:</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :return: Structure</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">standardize</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">sym_prec</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">standardize_structure</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">_structure</span><span class="p">,</span>
                <span class="n">sym_prec</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">sym_prec</span><span class="p">,</span>
                <span class="n">international_monoclinic</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">international_monoclinic</span><span class="p">,</span>
            <span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_structure</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">incar</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Incar</span><span class="p">:</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :return: Incar</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">settings</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_config_dict</span><span class="p">[</span><span class="s2">&quot;INCAR&quot;</span><span class="p">])</span>
        <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">user_incar_settings</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
            <span class="k">if</span> <span class="n">v</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
                <span class="k">try</span><span class="p">:</span>
                    <span class="k">del</span> <span class="n">settings</span><span class="p">[</span><span class="n">k</span><span class="p">]</span>
                <span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span>
                    <span class="n">settings</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="n">v</span>
            <span class="k">elif</span> <span class="n">k</span> <span class="o">==</span> <span class="s2">&quot;KSPACING&quot;</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">user_kpoints_settings</span> <span class="o">!=</span> <span class="p">{}:</span>
                <span class="k">pass</span>  <span class="c1"># Ignore KSPACING if user_kpoints_settings are given</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">settings</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="n">v</span>
        <span class="n">structure</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">structure</span>
        <span class="n">incar</span> <span class="o">=</span> <span class="n">Incar</span><span class="p">()</span>
        <span class="n">comp</span> <span class="o">=</span> <span class="n">structure</span><span class="o">.</span><span class="n">composition</span>
        <span class="n">elements</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span>
            <span class="p">[</span><span class="n">el</span> <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">comp</span><span class="o">.</span><span class="n">elements</span> <span class="k">if</span> <span class="n">comp</span><span class="p">[</span><span class="n">el</span><span class="p">]</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">],</span> <span class="n">key</span><span class="o">=</span><span class="k">lambda</span> <span class="n">e</span><span class="p">:</span> <span class="n">e</span><span class="o">.</span><span class="n">X</span>
        <span class="p">)</span>
        <span class="n">most_electroneg</span> <span class="o">=</span> <span class="n">elements</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">symbol</span>
        <span class="n">poscar</span> <span class="o">=</span> <span class="n">Poscar</span><span class="p">(</span><span class="n">structure</span><span class="p">)</span>
        <span class="n">hubbard_u</span> <span class="o">=</span> <span class="n">settings</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;LDAU&quot;</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span>

        <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">settings</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
            <span class="k">if</span> <span class="n">k</span> <span class="o">==</span> <span class="s2">&quot;MAGMOM&quot;</span><span class="p">:</span>
                <span class="n">mag</span> <span class="o">=</span> <span class="p">[]</span>
                <span class="k">for</span> <span class="n">site</span> <span class="ow">in</span> <span class="n">structure</span><span class="p">:</span>
                    <span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">site</span><span class="p">,</span> <span class="s2">&quot;magmom&quot;</span><span class="p">):</span>
                        <span class="n">mag</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">site</span><span class="o">.</span><span class="n">magmom</span><span class="p">)</span>
                    <span class="k">elif</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">site</span><span class="o">.</span><span class="n">specie</span><span class="p">,</span> <span class="s2">&quot;spin&quot;</span><span class="p">):</span>
                        <span class="n">mag</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">site</span><span class="o">.</span><span class="n">specie</span><span class="o">.</span><span class="n">spin</span><span class="p">)</span>
                    <span class="k">elif</span> <span class="nb">str</span><span class="p">(</span><span class="n">site</span><span class="o">.</span><span class="n">specie</span><span class="p">)</span> <span class="ow">in</span> <span class="n">v</span><span class="p">:</span>
                        <span class="n">mag</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">v</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">site</span><span class="o">.</span><span class="n">specie</span><span class="p">)))</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="n">mag</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">v</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">site</span><span class="o">.</span><span class="n">specie</span><span class="o">.</span><span class="n">symbol</span><span class="p">,</span> <span class="mf">0.6</span><span class="p">))</span>
                <span class="n">incar</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="n">mag</span>
            <span class="k">elif</span> <span class="n">k</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">&quot;LDAUU&quot;</span><span class="p">,</span> <span class="s2">&quot;LDAUJ&quot;</span><span class="p">,</span> <span class="s2">&quot;LDAUL&quot;</span><span class="p">):</span>
                <span class="k">if</span> <span class="n">hubbard_u</span><span class="p">:</span>
                    <span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">structure</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">k</span><span class="o">.</span><span class="n">lower</span><span class="p">()):</span>
                        <span class="n">m</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span>
                            <span class="p">[</span>
                                <span class="p">(</span><span class="n">site</span><span class="o">.</span><span class="n">specie</span><span class="o">.</span><span class="n">symbol</span><span class="p">,</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">site</span><span class="p">,</span> <span class="n">k</span><span class="o">.</span><span class="n">lower</span><span class="p">()))</span>
                                <span class="k">for</span> <span class="n">site</span> <span class="ow">in</span> <span class="n">structure</span>
                            <span class="p">]</span>
                        <span class="p">)</span>
                        <span class="n">incar</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="n">m</span><span class="p">[</span><span class="n">sym</span><span class="p">]</span> <span class="k">for</span> <span class="n">sym</span> <span class="ow">in</span> <span class="n">poscar</span><span class="o">.</span><span class="n">site_symbols</span><span class="p">]</span>
                    <span class="c1"># lookup specific LDAU if specified for most_electroneg atom</span>
                    <span class="k">elif</span> <span class="n">most_electroneg</span> <span class="ow">in</span> <span class="n">v</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span>
                            <span class="n">v</span><span class="p">[</span><span class="n">most_electroneg</span><span class="p">],</span> <span class="nb">dict</span>
                    <span class="p">):</span>
                        <span class="n">incar</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span>
                            <span class="n">v</span><span class="p">[</span><span class="n">most_electroneg</span><span class="p">]</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">sym</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
                            <span class="k">for</span> <span class="n">sym</span> <span class="ow">in</span> <span class="n">poscar</span><span class="o">.</span><span class="n">site_symbols</span>
                        <span class="p">]</span>
                    <span class="c1"># else, use fallback LDAU value if it exists</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="n">incar</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span>
                            <span class="n">v</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">sym</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
                            <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">v</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">sym</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="p">(</span><span class="nb">float</span><span class="p">,</span> <span class="nb">int</span><span class="p">))</span>
                            <span class="k">else</span> <span class="mi">0</span>
                            <span class="k">for</span> <span class="n">sym</span> <span class="ow">in</span> <span class="n">poscar</span><span class="o">.</span><span class="n">site_symbols</span>
                        <span class="p">]</span>
            <span class="k">elif</span> <span class="n">k</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">&quot;EDIFF&quot;</span><span class="p">)</span> <span class="ow">and</span> <span class="n">k</span> <span class="o">!=</span> <span class="s2">&quot;EDIFFG&quot;</span><span class="p">:</span>
                <span class="k">if</span> <span class="s2">&quot;EDIFF&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">settings</span> <span class="ow">and</span> <span class="n">k</span> <span class="o">==</span> <span class="s2">&quot;EDIFF_PER_ATOM&quot;</span><span class="p">:</span>
                    <span class="n">incar</span><span class="p">[</span><span class="s2">&quot;EDIFF&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> <span class="o">*</span> <span class="n">structure</span><span class="o">.</span><span class="n">num_sites</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">incar</span><span class="p">[</span><span class="s2">&quot;EDIFF&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">settings</span><span class="p">[</span><span class="s2">&quot;EDIFF&quot;</span><span class="p">])</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">incar</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="n">v</span>

        <span class="n">has_u</span> <span class="o">=</span> <span class="n">hubbard_u</span> <span class="ow">and</span> <span class="nb">sum</span><span class="p">(</span><span class="n">incar</span><span class="p">[</span><span class="s2">&quot;LDAUU&quot;</span><span class="p">])</span> <span class="o">&gt;</span> <span class="mi">0</span>
        <span class="k">if</span> <span class="n">has_u</span><span class="p">:</span>
            <span class="c1"># modify LMAXMIX if LSDA+U and you have d or f electrons</span>
            <span class="c1"># note that if the user explicitly sets LMAXMIX in settings it will</span>
            <span class="c1"># override this logic.</span>
            <span class="k">if</span> <span class="s2">&quot;LMAXMIX&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">settings</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
                <span class="c1"># contains f-electrons</span>
                <span class="k">if</span> <span class="nb">any</span><span class="p">([</span><span class="n">el</span><span class="o">.</span><span class="n">Z</span> <span class="o">&gt;</span> <span class="mi">56</span> <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">structure</span><span class="o">.</span><span class="n">composition</span><span class="p">]):</span>
                    <span class="n">incar</span><span class="p">[</span><span class="s2">&quot;LMAXMIX&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">6</span>
                <span class="c1"># contains d-electrons</span>
                <span class="k">elif</span> <span class="nb">any</span><span class="p">([</span><span class="n">el</span><span class="o">.</span><span class="n">Z</span> <span class="o">&gt;</span> <span class="mi">20</span> <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">structure</span><span class="o">.</span><span class="n">composition</span><span class="p">]):</span>
                    <span class="n">incar</span><span class="p">[</span><span class="s2">&quot;LMAXMIX&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">4</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="nb">list</span><span class="p">(</span><span class="n">incar</span><span class="o">.</span><span class="n">keys</span><span class="p">()):</span>
                <span class="k">if</span> <span class="n">key</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">&quot;LDAU&quot;</span><span class="p">):</span>
                    <span class="k">del</span> <span class="n">incar</span><span class="p">[</span><span class="n">key</span><span class="p">]</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">constrain_total_magmom</span><span class="p">:</span>
            <span class="n">nupdown</span> <span class="o">=</span> <span class="nb">sum</span><span class="p">([</span><span class="n">mag</span> <span class="k">if</span> <span class="nb">abs</span><span class="p">(</span><span class="n">mag</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mf">0.6</span> <span class="k">else</span> <span class="mi">0</span> <span class="k">for</span> <span class="n">mag</span> <span class="ow">in</span> <span class="n">incar</span><span class="p">[</span><span class="s2">&quot;MAGMOM&quot;</span><span class="p">]])</span>
            <span class="n">incar</span><span class="p">[</span><span class="s2">&quot;NUPDOWN&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">nupdown</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">use_structure_charge</span><span class="p">:</span>
            <span class="n">incar</span><span class="p">[</span><span class="s2">&quot;NELECT&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">nelect</span>

        <span class="c1"># Ensure adequate number of KPOINTS are present for the tetrahedron</span>
        <span class="c1"># method (ISMEAR=-5). If KSPACING is in the INCAR file the number</span>
        <span class="c1"># of kpoints is not known before calling VASP, but a warning is raised</span>
        <span class="c1"># when the KSPACING value is &gt; 0.5 (2 reciprocal Angstrom).</span>
        <span class="c1"># An error handler in Custodian is available to</span>
        <span class="c1"># correct overly large KSPACING values (small number of kpoints)</span>
        <span class="c1"># if necessary.</span>
        <span class="c1"># if &quot;KSPACING&quot; not in self.user_incar_settings.keys():</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">kpoints</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">np</span><span class="o">.</span><span class="n">product</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">kpoints</span><span class="o">.</span><span class="n">kpts</span><span class="p">)</span> <span class="o">&lt;</span> <span class="mi">4</span> <span class="ow">and</span> <span class="n">incar</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;ISMEAR&quot;</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="o">==</span> <span class="o">-</span><span class="mi">5</span><span class="p">:</span>
                <span class="n">incar</span><span class="p">[</span><span class="s2">&quot;ISMEAR&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">user_incar_settings</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;KSPACING&quot;</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mf">0.5</span> <span class="ow">and</span> <span class="n">incar</span><span class="o">.</span><span class="n">get</span><span class="p">(</span>
                <span class="s2">&quot;ISMEAR&quot;</span><span class="p">,</span> <span class="mi">0</span> <span class="o">==</span> <span class="o">-</span><span class="mi">5</span>
        <span class="p">):</span>
            <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span>
                <span class="s2">&quot;Large KSPACING value detected with ISMEAR = -5. Ensure that VASP &quot;</span>
                <span class="s2">&quot;generates an adequate number of KPOINTS, lower KSPACING, or &quot;</span>
                <span class="s2">&quot;set ISMEAR = 0&quot;</span><span class="p">,</span>
                <span class="n">BadInputSetWarning</span><span class="p">,</span>
            <span class="p">)</span>

        <span class="k">if</span> <span class="nb">all</span><span class="p">([</span><span class="n">k</span><span class="o">.</span><span class="n">is_metal</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">structure</span><span class="o">.</span><span class="n">composition</span><span class="o">.</span><span class="n">keys</span><span class="p">()]):</span>
            <span class="k">if</span> <span class="n">incar</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;NSW&quot;</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span> <span class="ow">and</span> <span class="n">incar</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;ISMEAR&quot;</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> <span class="o">&lt;</span> <span class="mi">1</span><span class="p">:</span>
                <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span>
                    <span class="s2">&quot;Relaxation of likely metal with ISMEAR &lt; 1 &quot;</span>
                    <span class="s2">&quot;detected. Please see VASP recommendations on &quot;</span>
                    <span class="s2">&quot;ISMEAR for metals.&quot;</span><span class="p">,</span>
                    <span class="n">BadInputSetWarning</span><span class="p">,</span>
                <span class="p">)</span>

        <span class="k">return</span> <span class="n">incar</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">poscar</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Poscar</span><span class="p">:</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :return: Poscar</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="n">Poscar</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">structure</span><span class="p">)</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">nelect</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">float</span><span class="p">:</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Gets the default number of electrons for a given structure.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="c1"># if structure is not sorted this can cause problems, so must take</span>
        <span class="c1"># care to remove redundant symbols when counting electrons</span>
        <span class="n">site_symbols</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">poscar</span><span class="o">.</span><span class="n">site_symbols</span><span class="p">))</span>
        <span class="n">structure</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">structure</span>
        <span class="n">nelect</span> <span class="o">=</span> <span class="mf">0.0</span>
        <span class="k">for</span> <span class="n">ps</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">potcar</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">ps</span><span class="o">.</span><span class="n">element</span> <span class="ow">in</span> <span class="n">site_symbols</span><span class="p">:</span>
                <span class="n">site_symbols</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">ps</span><span class="o">.</span><span class="n">element</span><span class="p">)</span>
                <span class="n">nelect</span> <span class="o">+=</span> <span class="p">(</span>
                        <span class="n">structure</span><span class="o">.</span><span class="n">composition</span><span class="o">.</span><span class="n">element_composition</span><span class="p">[</span><span class="n">ps</span><span class="o">.</span><span class="n">element</span><span class="p">]</span> <span class="o">*</span> <span class="n">ps</span><span class="o">.</span><span class="n">ZVAL</span>
                <span class="p">)</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">use_structure_charge</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">nelect</span> <span class="o">-</span> <span class="n">structure</span><span class="o">.</span><span class="n">charge</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">nelect</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">kpoints</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Union</span><span class="p">[</span><span class="n">Kpoints</span><span class="p">,</span> <span class="kc">None</span><span class="p">]:</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Returns a KPOINTS file using the fully automated grid method. Uses</span>
<span class="sd">        Gamma centered meshes for hexagonal cells and Monk grids otherwise.</span>

<span class="sd">        If KSPACING is set in user_incar_settings (or the INCAR file), no</span>
<span class="sd">        file is created because VASP will automatically generate the kpoints.</span>

<span class="sd">        Algorithm:</span>
<span class="sd">            Uses a simple approach scaling the number of divisions along each</span>
<span class="sd">            reciprocal lattice vector proportional to its length.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="c1"># Return None if KSPACING is present in the INCAR, because this will</span>
        <span class="c1"># cause VASP to generate the kpoints automatically</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">user_incar_settings</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;KSPACING&quot;</span><span class="p">)</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_config_dict</span><span class="p">[</span><span class="s2">&quot;INCAR&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">get</span><span class="p">(</span>
                <span class="s2">&quot;KSPACING&quot;</span>
        <span class="p">):</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">user_kpoints_settings</span> <span class="o">==</span> <span class="p">{}:</span>
                <span class="k">return</span> <span class="kc">None</span>

        <span class="n">settings</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">user_kpoints_settings</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_config_dict</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;KPOINTS&quot;</span><span class="p">)</span>

        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">settings</span><span class="p">,</span> <span class="n">Kpoints</span><span class="p">):</span>
            <span class="k">return</span> <span class="n">settings</span>

        <span class="c1"># Return None if KSPACING is present in the INCAR, because this will</span>
        <span class="c1"># cause VASP to generate the kpoints automatically</span>
        <span class="k">if</span> <span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">user_incar_settings</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;KSPACING&quot;</span><span class="p">)</span>
                <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">user_kpoints_settings</span> <span class="o">==</span> <span class="p">{}</span>
        <span class="p">):</span>
            <span class="k">return</span> <span class="kc">None</span>

        <span class="c1"># If grid_density is in the kpoints_settings use</span>
        <span class="c1"># Kpoints.automatic_density</span>
        <span class="k">if</span> <span class="n">settings</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;grid_density&quot;</span><span class="p">):</span>
            <span class="k">return</span> <span class="n">Kpoints</span><span class="o">.</span><span class="n">automatic_density</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">structure</span><span class="p">,</span> <span class="nb">int</span><span class="p">(</span><span class="n">settings</span><span class="p">[</span><span class="s2">&quot;grid_density&quot;</span><span class="p">]),</span> <span class="bp">self</span><span class="o">.</span><span class="n">force_gamma</span>
            <span class="p">)</span>

        <span class="c1"># If reciprocal_density is in the kpoints_settings use</span>
        <span class="c1"># Kpoints.automatic_density_by_vol</span>
        <span class="k">elif</span> <span class="n">settings</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;reciprocal_density&quot;</span><span class="p">):</span>
            <span class="k">return</span> <span class="n">Kpoints</span><span class="o">.</span><span class="n">automatic_density_by_vol</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">structure</span><span class="p">,</span> <span class="nb">int</span><span class="p">(</span><span class="n">settings</span><span class="p">[</span><span class="s2">&quot;reciprocal_density&quot;</span><span class="p">]),</span> <span class="bp">self</span><span class="o">.</span><span class="n">force_gamma</span>
            <span class="p">)</span>

        <span class="c1"># If length is in the kpoints_settings use Kpoints.automatic</span>
        <span class="k">elif</span> <span class="n">settings</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;length&quot;</span><span class="p">):</span>
            <span class="k">return</span> <span class="n">Kpoints</span><span class="o">.</span><span class="n">automatic</span><span class="p">(</span><span class="n">settings</span><span class="p">[</span><span class="s2">&quot;length&quot;</span><span class="p">])</span>

        <span class="c1"># Raise error. Unsure of which kpoint generation to use</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;Invalid KPoint Generation algo : Supported Keys are &quot;</span>
                <span class="s2">&quot;grid_density: for Kpoints.automatic_density generation, &quot;</span>
                <span class="s2">&quot;reciprocal_density: for KPoints.automatic_density_by_vol &quot;</span>
                <span class="s2">&quot;generation, and length  : for Kpoints.automatic generation&quot;</span>
            <span class="p">)</span>

    <span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span>

    <span class="k">def</span> <span class="fm">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span>

<div class="viewcode-block" id="DictSet.write_input"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.DictSet.write_input">[docs]</a>    <span class="k">def</span> <span class="nf">write_input</span><span class="p">(</span>
            <span class="bp">self</span><span class="p">,</span>
            <span class="n">output_dir</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span>
            <span class="n">make_dir_if_not_present</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span>
            <span class="n">include_cif</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span>
            <span class="n">potcar_spec</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span>
            <span class="n">zip_output</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span>
    <span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Writes out all input to a directory.</span>

<span class="sd">        Args:</span>
<span class="sd">            output_dir (str): Directory to output the VASP input files</span>
<span class="sd">            make_dir_if_not_present (bool): Set to True if you want the</span>
<span class="sd">                directory (and the whole path) to be created if it is not</span>
<span class="sd">                present.</span>
<span class="sd">            include_cif (bool): Whether to write a CIF file in the output</span>
<span class="sd">                directory for easier opening by VESTA.</span>
<span class="sd">            potcar_spec (bool): Instead of writing the POTCAR, write a &quot;POTCAR.spec&quot;.</span>
<span class="sd">                This is intended to help sharing an input set with people who might</span>
<span class="sd">                not have a license to specific Potcar files. Given a &quot;POTCAR.spec&quot;,</span>
<span class="sd">                the specific POTCAR file can be re-generated using pymatgen with the</span>
<span class="sd">                &quot;generate_potcar&quot; function in the pymatgen CLI.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">write_input</span><span class="p">(</span>
            <span class="n">output_dir</span><span class="o">=</span><span class="n">output_dir</span><span class="p">,</span>
            <span class="n">make_dir_if_not_present</span><span class="o">=</span><span class="n">make_dir_if_not_present</span><span class="p">,</span>
            <span class="n">include_cif</span><span class="o">=</span><span class="n">include_cif</span><span class="p">,</span>
            <span class="n">potcar_spec</span><span class="o">=</span><span class="n">potcar_spec</span><span class="p">,</span>
            <span class="n">zip_output</span><span class="o">=</span><span class="n">zip_output</span>
        <span class="p">)</span>
        <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">files_to_transfer</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
            <span class="k">with</span> <span class="n">zopen</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="s2">&quot;rb&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">fin</span><span class="p">,</span> <span class="n">zopen</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">Path</span><span class="p">(</span><span class="n">output_dir</span><span class="p">)</span> <span class="o">/</span> <span class="n">k</span><span class="p">),</span> <span class="s2">&quot;wb&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">fout</span><span class="p">:</span>
                <span class="n">shutil</span><span class="o">.</span><span class="n">copyfileobj</span><span class="p">(</span><span class="n">fin</span><span class="p">,</span> <span class="n">fout</span><span class="p">)</span></div></div>


<div class="viewcode-block" id="MITRelaxSet"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.MITRelaxSet">[docs]</a><span class="k">class</span> <span class="nc">MITRelaxSet</span><span class="p">(</span><span class="n">DictSet</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Standard implementation of VaspInputSet utilizing parameters in the MIT</span>
<span class="sd">    High-throughput project.</span>
<span class="sd">    The parameters are chosen specifically for a high-throughput project,</span>
<span class="sd">    which means in general pseudopotentials with fewer electrons were chosen.</span>

<span class="sd">    Please refer::</span>

<span class="sd">        A Jain, G. Hautier, C. Moore, S. P. Ong, C. Fischer, T. Mueller,</span>
<span class="sd">        K. A. Persson, G. Ceder. A high-throughput infrastructure for density</span>
<span class="sd">        functional theory calculations. Computational Materials Science,</span>
<span class="sd">        2011, 50(8), 2295-2310. doi:10.1016/j.commatsci.2011.02.023</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="n">CONFIG</span> <span class="o">=</span> <span class="n">_load_yaml_config</span><span class="p">(</span><span class="s2">&quot;MITRelaxSet&quot;</span><span class="p">)</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">structure</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :param structure: Structure</span>
<span class="sd">        :param kwargs: Same as those supported by DictSet.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">structure</span><span class="p">,</span> <span class="n">MITRelaxSet</span><span class="o">.</span><span class="n">CONFIG</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">kwargs</span> <span class="o">=</span> <span class="n">kwargs</span></div>


<div class="viewcode-block" id="MPRelaxSet"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.MPRelaxSet">[docs]</a><span class="k">class</span> <span class="nc">MPRelaxSet</span><span class="p">(</span><span class="n">DictSet</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Implementation of VaspInputSet utilizing parameters in the public</span>
<span class="sd">    Materials Project. Typically, the pseudopotentials chosen contain more</span>
<span class="sd">    electrons than the MIT parameters, and the k-point grid is ~50% more dense.</span>
<span class="sd">    The LDAUU parameters are also different due to the different psps used,</span>
<span class="sd">    which result in different fitted values.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="n">CONFIG</span> <span class="o">=</span> <span class="n">_load_yaml_config</span><span class="p">(</span><span class="s2">&quot;MPRelaxSet&quot;</span><span class="p">)</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">structure</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :param structure: Structure</span>
<span class="sd">        :param kwargs: Same as those supported by DictSet.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">structure</span><span class="p">,</span> <span class="n">MPRelaxSet</span><span class="o">.</span><span class="n">CONFIG</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">kwargs</span> <span class="o">=</span> <span class="n">kwargs</span></div>


<div class="viewcode-block" id="MPScanRelaxSet"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.MPScanRelaxSet">[docs]</a><span class="k">class</span> <span class="nc">MPScanRelaxSet</span><span class="p">(</span><span class="n">DictSet</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Class for writing a relax input set using Strongly Constrained and</span>
<span class="sd">    Appropriately Normed (SCAN) semilocal density functional.</span>

<span class="sd">    Notes:</span>
<span class="sd">        1. This functional is only available from VASP.5.4.3 upwards.</span>

<span class="sd">        2. Meta-GGA calculations require POTCAR files that include</span>
<span class="sd">        information on the kinetic energy density of the core-electrons,</span>
<span class="sd">        i.e. &quot;PBE_52&quot; or &quot;PBE_54&quot;. Make sure the POTCARs include the</span>
<span class="sd">        following lines (see VASP wiki for more details):</span>

<span class="sd">            $ grep kinetic POTCAR</span>
<span class="sd">            kinetic energy-density</span>
<span class="sd">            mkinetic energy-density pseudized</span>
<span class="sd">            kinetic energy density (partial)</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="n">CONFIG</span> <span class="o">=</span> <span class="n">_load_yaml_config</span><span class="p">(</span><span class="s2">&quot;MPSCANRelaxSet&quot;</span><span class="p">)</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">structure</span><span class="p">,</span> <span class="n">bandgap</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            structure (Structure): Input structure.</span>
<span class="sd">            bandgap (int): Bandgap of the structure in eV. The bandgap is used to</span>
<span class="sd">                    compute the appropriate k-point density and determine the</span>
<span class="sd">                    smearing settings.</span>

<span class="sd">                    Metallic systems (default, bandgap = 0) use a KSPACING value of 0.22</span>
<span class="sd">                    and Methfessel-Paxton order 2 smearing (ISMEAR=2, SIGMA=0.2).</span>

<span class="sd">                    Non-metallic systems (bandgap &gt; 0) use the tetrahedron smearing</span>
<span class="sd">                    method (ISMEAR=-5, SIGMA=0.05). The KSPACING value is</span>
<span class="sd">                    calculated from the bandgap via Eqs. 25 and 29 of Wisesa, McGill,</span>
<span class="sd">                    and Mueller [1] (see References). Note that if &#39;user_incar_settings&#39;</span>
<span class="sd">                    or &#39;user_kpoints_settings&#39; override KSPACING, the calculation from</span>
<span class="sd">                    bandgap is not performed.</span>

<span class="sd">            vdw (str): set &quot;rVV10&quot; to enable SCAN+rVV10, which is a versatile</span>
<span class="sd">                    van der Waals density functional by combing the SCAN functional</span>
<span class="sd">                    with the rVV10 non-local correlation functional. rvv10 is the only</span>
<span class="sd">                    dispersion correction available for SCAN at this time.</span>
<span class="sd">            **kwargs: Same as those supported by DictSet.</span>

<span class="sd">        References:</span>
<span class="sd">            [1] P. Wisesa, K.A. McGill, T. Mueller, Efficient generation of</span>
<span class="sd">            generalized Monkhorst-Pack grids through the use of informatics,</span>
<span class="sd">            Phys. Rev. B. 93 (2016) 1–10. doi:10.1103/PhysRevB.93.155109.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">structure</span><span class="p">,</span> <span class="n">MPScanRelaxSet</span><span class="o">.</span><span class="n">CONFIG</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">bandgap</span> <span class="o">=</span> <span class="n">bandgap</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">kwargs</span> <span class="o">=</span> <span class="n">kwargs</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">potcar_functional</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;PBE_52&quot;</span><span class="p">,</span> <span class="s2">&quot;PBE_54&quot;</span><span class="p">]:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;SCAN calculations require PBE_52 or PBE_54!&quot;</span><span class="p">)</span>

        <span class="c1"># self.kwargs.get(&quot;user_incar_settings&quot;, {</span>
        <span class="n">updates</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="c1"># select the KSPACING and smearing parameters based on the bandgap</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">bandgap</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
            <span class="n">updates</span><span class="p">[</span><span class="s2">&quot;KSPACING&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="mf">0.22</span>
            <span class="n">updates</span><span class="p">[</span><span class="s2">&quot;SIGMA&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="mf">0.2</span>
            <span class="n">updates</span><span class="p">[</span><span class="s2">&quot;ISMEAR&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">2</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">rmin</span> <span class="o">=</span> <span class="mf">25.22</span> <span class="o">-</span> <span class="mf">1.87</span> <span class="o">*</span> <span class="n">bandgap</span>  <span class="c1"># Eq. 25</span>
            <span class="n">kspacing</span> <span class="o">=</span> <span class="mi">2</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">pi</span> <span class="o">*</span> <span class="mf">1.0265</span> <span class="o">/</span> <span class="p">(</span><span class="n">rmin</span> <span class="o">-</span> <span class="mf">1.0183</span><span class="p">)</span>  <span class="c1"># Eq. 29</span>
            <span class="c1"># cap the KSPACING at a max of 0.44, per internal benchmarking</span>
            <span class="k">if</span> <span class="n">kspacing</span> <span class="o">&gt;</span> <span class="mf">0.44</span><span class="p">:</span>
                <span class="n">kspacing</span> <span class="o">=</span> <span class="mf">0.44</span>
            <span class="n">updates</span><span class="p">[</span><span class="s2">&quot;KSPACING&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">kspacing</span>
            <span class="n">updates</span><span class="p">[</span><span class="s2">&quot;ISMEAR&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="o">-</span><span class="mi">5</span>
            <span class="n">updates</span><span class="p">[</span><span class="s2">&quot;SIGMA&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="mf">0.05</span>

        <span class="c1"># Don&#39;t overwrite things the user has supplied</span>
        <span class="k">if</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;user_incar_settings&quot;</span><span class="p">,</span> <span class="p">{})</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;KSPACING&quot;</span><span class="p">):</span>
            <span class="k">del</span> <span class="n">updates</span><span class="p">[</span><span class="s2">&quot;KSPACING&quot;</span><span class="p">]</span>

        <span class="k">if</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;user_incar_settings&quot;</span><span class="p">,</span> <span class="p">{})</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;ISMEAR&quot;</span><span class="p">):</span>
            <span class="k">del</span> <span class="n">updates</span><span class="p">[</span><span class="s2">&quot;ISMEAR&quot;</span><span class="p">]</span>

        <span class="k">if</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;user_incar_settings&quot;</span><span class="p">,</span> <span class="p">{})</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;SIGMA&quot;</span><span class="p">):</span>
            <span class="k">del</span> <span class="n">updates</span><span class="p">[</span><span class="s2">&quot;SIGMA&quot;</span><span class="p">]</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">vdw</span><span class="p">:</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">vdw</span> <span class="o">!=</span> <span class="s2">&quot;rvv10&quot;</span><span class="p">:</span>
                <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span>
                    <span class="s2">&quot;Use of van der waals functionals other than rVV10 &quot;</span>
                    <span class="s2">&quot;with SCAN is not supported at this time. &quot;</span>
                <span class="p">)</span>
                <span class="c1"># delete any vdw parameters that may have been added to the INCAR</span>
                <span class="n">vdw_par</span> <span class="o">=</span> <span class="n">loadfn</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">MODULE_DIR</span> <span class="o">/</span> <span class="s2">&quot;vdW_parameters.yaml&quot;</span><span class="p">))</span>
                <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">vdw_par</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">vdw</span><span class="p">]</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
                    <span class="k">try</span><span class="p">:</span>
                        <span class="k">del</span> <span class="bp">self</span><span class="o">.</span><span class="n">_config_dict</span><span class="p">[</span><span class="s2">&quot;INCAR&quot;</span><span class="p">][</span><span class="n">k</span><span class="p">]</span>
                    <span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span>
                        <span class="k">pass</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">_config_dict</span><span class="p">[</span><span class="s2">&quot;INCAR&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">updates</span><span class="p">)</span></div>


<div class="viewcode-block" id="MPMetalRelaxSet"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.MPMetalRelaxSet">[docs]</a><span class="k">class</span> <span class="nc">MPMetalRelaxSet</span><span class="p">(</span><span class="n">MPRelaxSet</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Implementation of VaspInputSet utilizing parameters in the public</span>
<span class="sd">    Materials Project, but with tuning for metals. Key things are a denser</span>
<span class="sd">    k point density, and a</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="n">CONFIG</span> <span class="o">=</span> <span class="n">_load_yaml_config</span><span class="p">(</span><span class="s2">&quot;MPRelaxSet&quot;</span><span class="p">)</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">structure</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :param structure: Structure</span>
<span class="sd">        :param kwargs: Same as those supported by DictSet.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">structure</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_config_dict</span><span class="p">[</span><span class="s2">&quot;INCAR&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">update</span><span class="p">({</span><span class="s2">&quot;ISMEAR&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">&quot;SIGMA&quot;</span><span class="p">:</span> <span class="mf">0.2</span><span class="p">})</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_config_dict</span><span class="p">[</span><span class="s2">&quot;KPOINTS&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">update</span><span class="p">({</span><span class="s2">&quot;reciprocal_density&quot;</span><span class="p">:</span> <span class="mi">200</span><span class="p">})</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">kwargs</span> <span class="o">=</span> <span class="n">kwargs</span></div>


<div class="viewcode-block" id="MPHSERelaxSet"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.MPHSERelaxSet">[docs]</a><span class="k">class</span> <span class="nc">MPHSERelaxSet</span><span class="p">(</span><span class="n">DictSet</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Same as the MPRelaxSet, but with HSE parameters.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="n">CONFIG</span> <span class="o">=</span> <span class="n">_load_yaml_config</span><span class="p">(</span><span class="s2">&quot;MPHSERelaxSet&quot;</span><span class="p">)</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">structure</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :param structure: Structure</span>
<span class="sd">        :param kwargs: Same as those supported by DictSet.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">structure</span><span class="p">,</span> <span class="n">MPHSERelaxSet</span><span class="o">.</span><span class="n">CONFIG</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">kwargs</span> <span class="o">=</span> <span class="n">kwargs</span></div>


<div class="viewcode-block" id="MPStaticSet"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.MPStaticSet">[docs]</a><span class="k">class</span> <span class="nc">MPStaticSet</span><span class="p">(</span><span class="n">MPRelaxSet</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Creates input files for a static calculation.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span>
            <span class="bp">self</span><span class="p">,</span>
            <span class="n">structure</span><span class="p">,</span>
            <span class="n">prev_incar</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
            <span class="n">prev_kpoints</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
            <span class="n">lepsilon</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
            <span class="n">lcalcpol</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
            <span class="n">reciprocal_density</span><span class="o">=</span><span class="mi">100</span><span class="p">,</span>
            <span class="n">small_gap_multiply</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
            <span class="o">**</span><span class="n">kwargs</span>
    <span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            structure (Structure): Structure from previous run.</span>
<span class="sd">            prev_incar (Incar): Incar file from previous run.</span>
<span class="sd">            prev_kpoints (Kpoints): Kpoints from previous run.</span>
<span class="sd">            lepsilon (bool): Whether to add static dielectric calculation</span>
<span class="sd">            reciprocal_density (int): For static calculations, we usually set the</span>
<span class="sd">                reciprocal density by volume. This is a convenience arg to change</span>
<span class="sd">                that, rather than using user_kpoints_settings. Defaults to 100,</span>
<span class="sd">                which is ~50% more than that of standard relaxation calculations.</span>
<span class="sd">            small_gap_multiply ([float, float]): If the gap is less than</span>
<span class="sd">                1st index, multiply the default reciprocal_density by the 2nd</span>
<span class="sd">                index.</span>
<span class="sd">            **kwargs: kwargs supported by MPRelaxSet.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">structure</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">prev_incar</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span>
            <span class="n">prev_incar</span> <span class="o">=</span> <span class="n">Incar</span><span class="o">.</span><span class="n">from_file</span><span class="p">(</span><span class="n">prev_incar</span><span class="p">)</span>
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">prev_kpoints</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span>
            <span class="n">prev_kpoints</span> <span class="o">=</span> <span class="n">Kpoints</span><span class="o">.</span><span class="n">from_file</span><span class="p">(</span><span class="n">prev_kpoints</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">prev_incar</span> <span class="o">=</span> <span class="n">prev_incar</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">prev_kpoints</span> <span class="o">=</span> <span class="n">prev_kpoints</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">reciprocal_density</span> <span class="o">=</span> <span class="n">reciprocal_density</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">kwargs</span> <span class="o">=</span> <span class="n">kwargs</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">lepsilon</span> <span class="o">=</span> <span class="n">lepsilon</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">lcalcpol</span> <span class="o">=</span> <span class="n">lcalcpol</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">small_gap_multiply</span> <span class="o">=</span> <span class="n">small_gap_multiply</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">incar</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :return: Incar</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">parent_incar</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">incar</span>
        <span class="n">incar</span> <span class="o">=</span> <span class="p">(</span>
            <span class="n">Incar</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">prev_incar</span><span class="p">)</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">prev_incar</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span>
            <span class="k">else</span> <span class="n">Incar</span><span class="p">(</span><span class="n">parent_incar</span><span class="p">)</span>
        <span class="p">)</span>

        <span class="n">incar</span><span class="o">.</span><span class="n">update</span><span class="p">(</span>
            <span class="p">{</span>
                <span class="s2">&quot;IBRION&quot;</span><span class="p">:</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span>
                <span class="s2">&quot;ISMEAR&quot;</span><span class="p">:</span> <span class="o">-</span><span class="mi">5</span><span class="p">,</span>
                <span class="s2">&quot;LAECHG&quot;</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span>
                <span class="s2">&quot;LCHARG&quot;</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span>
                <span class="s2">&quot;LORBIT&quot;</span><span class="p">:</span> <span class="mi">11</span><span class="p">,</span>
                <span class="s2">&quot;LVHAR&quot;</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span>
                <span class="s2">&quot;LWAVE&quot;</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span>
                <span class="s2">&quot;NSW&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
                <span class="s2">&quot;ICHARG&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
                <span class="s2">&quot;ALGO&quot;</span><span class="p">:</span> <span class="s2">&quot;Normal&quot;</span><span class="p">,</span>
            <span class="p">}</span>
        <span class="p">)</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">lepsilon</span><span class="p">:</span>
            <span class="n">incar</span><span class="p">[</span><span class="s2">&quot;IBRION&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">8</span>
            <span class="n">incar</span><span class="p">[</span><span class="s2">&quot;LEPSILON&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>

            <span class="c1"># LPEAD=T: numerical evaluation of overlap integral prevents</span>
            <span class="c1"># LRF_COMMUTATOR errors and can lead to better expt. agreement</span>
            <span class="c1"># but produces slightly different results</span>
            <span class="n">incar</span><span class="p">[</span><span class="s2">&quot;LPEAD&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>

            <span class="c1"># Note that DFPT calculations MUST unset NSW. NSW = 0 will fail</span>
            <span class="c1"># to output ionic.</span>
            <span class="n">incar</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">&quot;NSW&quot;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
            <span class="n">incar</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">&quot;NPAR&quot;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">lcalcpol</span><span class="p">:</span>
            <span class="n">incar</span><span class="p">[</span><span class="s2">&quot;LCALCPOL&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>

        <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;MAGMOM&quot;</span><span class="p">,</span> <span class="s2">&quot;NUPDOWN&quot;</span><span class="p">]</span> <span class="o">+</span> <span class="nb">list</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;user_incar_settings&quot;</span><span class="p">,</span> <span class="p">{})</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span>
        <span class="p">):</span>
            <span class="c1"># For these parameters as well as user specified settings, override</span>
            <span class="c1"># the incar settings.</span>
            <span class="k">if</span> <span class="n">parent_incar</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
                <span class="n">incar</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="n">parent_incar</span><span class="p">[</span><span class="n">k</span><span class="p">]</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">incar</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>

        <span class="c1"># use new LDAUU when possible b/c the Poscar might have changed</span>
        <span class="c1"># representation</span>
        <span class="k">if</span> <span class="n">incar</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;LDAU&quot;</span><span class="p">):</span>
            <span class="n">u</span> <span class="o">=</span> <span class="n">incar</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;LDAUU&quot;</span><span class="p">,</span> <span class="p">[])</span>
            <span class="n">j</span> <span class="o">=</span> <span class="n">incar</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;LDAUJ&quot;</span><span class="p">,</span> <span class="p">[])</span>
            <span class="k">if</span> <span class="nb">sum</span><span class="p">([</span><span class="n">u</span><span class="p">[</span><span class="n">x</span><span class="p">]</span> <span class="o">-</span> <span class="n">j</span><span class="p">[</span><span class="n">x</span><span class="p">]</span> <span class="k">for</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">u</span><span class="p">)])</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
                <span class="k">for</span> <span class="n">tag</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">&quot;LDAUU&quot;</span><span class="p">,</span> <span class="s2">&quot;LDAUL&quot;</span><span class="p">,</span> <span class="s2">&quot;LDAUJ&quot;</span><span class="p">):</span>
                    <span class="n">incar</span><span class="o">.</span><span class="n">update</span><span class="p">({</span><span class="n">tag</span><span class="p">:</span> <span class="n">parent_incar</span><span class="p">[</span><span class="n">tag</span><span class="p">]})</span>
            <span class="c1"># ensure to have LMAXMIX for GGA+U static run</span>
            <span class="k">if</span> <span class="s2">&quot;LMAXMIX&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">incar</span><span class="p">:</span>
                <span class="n">incar</span><span class="o">.</span><span class="n">update</span><span class="p">({</span><span class="s2">&quot;LMAXMIX&quot;</span><span class="p">:</span> <span class="n">parent_incar</span><span class="p">[</span><span class="s2">&quot;LMAXMIX&quot;</span><span class="p">]})</span>

        <span class="c1"># Compare ediff between previous and staticinputset values,</span>
        <span class="c1"># choose the tighter ediff</span>
        <span class="n">incar</span><span class="p">[</span><span class="s2">&quot;EDIFF&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">min</span><span class="p">(</span><span class="n">incar</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;EDIFF&quot;</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">parent_incar</span><span class="p">[</span><span class="s2">&quot;EDIFF&quot;</span><span class="p">])</span>
        <span class="k">return</span> <span class="n">incar</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">kpoints</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Optional</span><span class="p">[</span><span class="n">Kpoints</span><span class="p">]:</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :return: Kpoints</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_config_dict</span><span class="p">[</span><span class="s2">&quot;KPOINTS&quot;</span><span class="p">][</span><span class="s2">&quot;reciprocal_density&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">reciprocal_density</span>
        <span class="n">kpoints</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">kpoints</span>

        <span class="c1"># Prefer to use k-point scheme from previous run</span>
        <span class="c1"># except for when lepsilon = True is specified</span>
        <span class="k">if</span> <span class="n">kpoints</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">prev_kpoints</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">prev_kpoints</span><span class="o">.</span><span class="n">style</span> <span class="o">!=</span> <span class="n">kpoints</span><span class="o">.</span><span class="n">style</span><span class="p">:</span>
                <span class="k">if</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">prev_kpoints</span><span class="o">.</span><span class="n">style</span> <span class="o">==</span> <span class="n">Kpoints</span><span class="o">.</span><span class="n">supported_modes</span><span class="o">.</span><span class="n">Monkhorst</span><span class="p">)</span> <span class="ow">and</span> <span class="p">(</span>
                        <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">lepsilon</span>
                <span class="p">):</span>
                    <span class="n">k_div</span> <span class="o">=</span> <span class="p">[</span><span class="n">kp</span> <span class="o">+</span> <span class="mi">1</span> <span class="k">if</span> <span class="n">kp</span> <span class="o">%</span> <span class="mi">2</span> <span class="o">==</span> <span class="mi">1</span> <span class="k">else</span> <span class="n">kp</span> <span class="k">for</span> <span class="n">kp</span> <span class="ow">in</span> <span class="n">kpoints</span><span class="o">.</span><span class="n">kpts</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span>
                    <span class="n">kpoints</span> <span class="o">=</span> <span class="n">Kpoints</span><span class="o">.</span><span class="n">monkhorst_automatic</span><span class="p">(</span><span class="n">k_div</span><span class="p">)</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">kpoints</span> <span class="o">=</span> <span class="n">Kpoints</span><span class="o">.</span><span class="n">gamma_automatic</span><span class="p">(</span><span class="n">kpoints</span><span class="o">.</span><span class="n">kpts</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
        <span class="k">return</span> <span class="n">kpoints</span>

<div class="viewcode-block" id="MPStaticSet.override_from_prev_calc"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.MPStaticSet.override_from_prev_calc">[docs]</a>    <span class="k">def</span> <span class="nf">override_from_prev_calc</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prev_calc_dir</span><span class="o">=</span><span class="s2">&quot;.&quot;</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Update the input set to include settings from a previous calculation.</span>

<span class="sd">        Args:</span>
<span class="sd">            prev_calc_dir (str): The path to the previous calculation directory.</span>

<span class="sd">        Returns:</span>
<span class="sd">            The input set with the settings (structure, k-points, incar, etc)</span>
<span class="sd">            updated using the previous VASP run.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">vasprun</span><span class="p">,</span> <span class="n">outcar</span> <span class="o">=</span> <span class="n">get_vasprun_outcar</span><span class="p">(</span><span class="n">prev_calc_dir</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">prev_incar</span> <span class="o">=</span> <span class="n">vasprun</span><span class="o">.</span><span class="n">incar</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">prev_kpoints</span> <span class="o">=</span> <span class="n">vasprun</span><span class="o">.</span><span class="n">kpoints</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">standardize</span><span class="p">:</span>
            <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span>
                <span class="s2">&quot;Use of standardize=True with from_prev_run is not &quot;</span>
                <span class="s2">&quot;recommended as there is no guarantee the copied &quot;</span>
                <span class="s2">&quot;files will be appropriate for the standardized &quot;</span>
                <span class="s2">&quot;structure.&quot;</span>
            <span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">_structure</span> <span class="o">=</span> <span class="n">get_structure_from_prev_run</span><span class="p">(</span><span class="n">vasprun</span><span class="p">,</span> <span class="n">outcar</span><span class="p">)</span>

        <span class="c1"># multiply the reciprocal density if needed</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">small_gap_multiply</span><span class="p">:</span>
            <span class="n">gap</span> <span class="o">=</span> <span class="n">vasprun</span><span class="o">.</span><span class="n">eigenvalue_band_properties</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
            <span class="k">if</span> <span class="n">gap</span> <span class="o">&lt;=</span> <span class="bp">self</span><span class="o">.</span><span class="n">small_gap_multiply</span><span class="p">[</span><span class="mi">0</span><span class="p">]:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">reciprocal_density</span> <span class="o">=</span> <span class="p">(</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">reciprocal_density</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">small_gap_multiply</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
                <span class="p">)</span>

        <span class="k">return</span> <span class="bp">self</span></div>

<div class="viewcode-block" id="MPStaticSet.from_prev_calc"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.MPStaticSet.from_prev_calc">[docs]</a>    <span class="nd">@classmethod</span>
    <span class="k">def</span> <span class="nf">from_prev_calc</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">prev_calc_dir</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Generate a set of Vasp input files for static calculations from a</span>
<span class="sd">        directory of previous Vasp run.</span>

<span class="sd">        Args:</span>
<span class="sd">            prev_calc_dir (str): Directory containing the outputs(</span>
<span class="sd">                vasprun.xml and OUTCAR) of previous vasp run.</span>
<span class="sd">            **kwargs: All kwargs supported by MPStaticSet, other than prev_incar</span>
<span class="sd">                and prev_structure and prev_kpoints which are determined from</span>
<span class="sd">                the prev_calc_dir.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">input_set</span> <span class="o">=</span> <span class="bp">cls</span><span class="p">(</span><span class="n">_dummy_structure</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">input_set</span><span class="o">.</span><span class="n">override_from_prev_calc</span><span class="p">(</span><span class="n">prev_calc_dir</span><span class="o">=</span><span class="n">prev_calc_dir</span><span class="p">)</span></div></div>


<div class="viewcode-block" id="MPHSEBSSet"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.MPHSEBSSet">[docs]</a><span class="k">class</span> <span class="nc">MPHSEBSSet</span><span class="p">(</span><span class="n">MPHSERelaxSet</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Implementation of a VaspInputSet for HSE band structure computations.</span>
<span class="sd">    Remember that HSE band structures must be self-consistent in VASP. A</span>
<span class="sd">    band structure along symmetry lines for instance needs BOTH a uniform</span>
<span class="sd">    grid with appropriate weights AND a path along the lines with weight 0.</span>

<span class="sd">    Thus, the &quot;Uniform&quot; mode is just like regular static SCF but allows</span>
<span class="sd">    adding custom kpoints (e.g., corresponding to known VBM/CBM) to the</span>
<span class="sd">    uniform grid that have zero weight (e.g., for better gap estimate).</span>

<span class="sd">    The &quot;Gap&quot; mode behaves just like the &quot;Uniform&quot; mode, however, if starting</span>
<span class="sd">    from a previous calculation, the VBM and CBM k-points will automatically</span>
<span class="sd">    be added to ``added_kpoints``.</span>

<span class="sd">    The &quot;Line&quot; mode is just like Uniform mode, but additionally adds</span>
<span class="sd">    k-points along symmetry lines with zero weight.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span>
            <span class="bp">self</span><span class="p">,</span>
            <span class="n">structure</span><span class="p">,</span>
            <span class="n">user_incar_settings</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
            <span class="n">added_kpoints</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
            <span class="n">mode</span><span class="o">=</span><span class="s2">&quot;Gap&quot;</span><span class="p">,</span>
            <span class="n">reciprocal_density</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
            <span class="n">copy_chgcar</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
            <span class="n">kpoints_line_density</span><span class="o">=</span><span class="mi">20</span><span class="p">,</span>
            <span class="o">**</span><span class="n">kwargs</span>
    <span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            structure (Structure): Structure to compute</span>
<span class="sd">            user_incar_settings (dict): A dict specifying additional incar</span>
<span class="sd">                settings</span>
<span class="sd">            added_kpoints (list): a list of kpoints (list of 3 number list)</span>
<span class="sd">                added to the run. The k-points are in fractional coordinates</span>
<span class="sd">            mode (str): &quot;Line&quot; - generate k-points along symmetry lines for</span>
<span class="sd">                bandstructure. &quot;Uniform&quot; - generate uniform k-points grid.</span>
<span class="sd">            reciprocal_density (int): k-point density to use for uniform mesh.</span>
<span class="sd">            copy_chgcar (bool): Whether to copy the CHGCAR of a previous run.</span>
<span class="sd">            kpoints_line_density (int): k-point density for high symmetry lines</span>
<span class="sd">            **kwargs (dict): Any other parameters to pass into DictSet.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">structure</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">user_incar_settings</span> <span class="o">=</span> <span class="n">user_incar_settings</span> <span class="ow">or</span> <span class="p">{}</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_config_dict</span><span class="p">[</span><span class="s2">&quot;INCAR&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">update</span><span class="p">(</span>
            <span class="p">{</span>
                <span class="s2">&quot;NSW&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
                <span class="s2">&quot;ISMEAR&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
                <span class="s2">&quot;SIGMA&quot;</span><span class="p">:</span> <span class="mf">0.05</span><span class="p">,</span>
                <span class="s2">&quot;ISYM&quot;</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
                <span class="s2">&quot;LCHARG&quot;</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span>
                <span class="s2">&quot;NELMIN&quot;</span><span class="p">:</span> <span class="mi">5</span><span class="p">,</span>
            <span class="p">}</span>
        <span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">added_kpoints</span> <span class="o">=</span> <span class="n">added_kpoints</span> <span class="k">if</span> <span class="n">added_kpoints</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> <span class="p">[]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">mode</span> <span class="o">=</span> <span class="n">mode</span>

        <span class="k">if</span> <span class="p">(</span>
                <span class="ow">not</span> <span class="n">reciprocal_density</span>
                <span class="ow">or</span> <span class="s2">&quot;reciprocal_density&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">user_kpoints_settings</span>
        <span class="p">):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">reciprocal_density</span> <span class="o">=</span> <span class="mi">50</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">reciprocal_density</span> <span class="o">=</span> <span class="p">(</span>
                    <span class="n">reciprocal_density</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">user_kpoints_settings</span><span class="p">[</span><span class="s2">&quot;reciprocal_density&quot;</span><span class="p">]</span>
            <span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">kpoints_line_density</span> <span class="o">=</span> <span class="n">kpoints_line_density</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">copy_chgcar</span> <span class="o">=</span> <span class="n">copy_chgcar</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">kpoints</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Kpoints</span><span class="p">:</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :return: Kpoints</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">kpts</span> <span class="o">=</span> <span class="p">[]</span>  <span class="c1"># type: List[Union[int, float, None]]</span>
        <span class="n">weights</span> <span class="o">=</span> <span class="p">[]</span>  <span class="c1"># type: List[Union[float, None]]</span>
        <span class="n">all_labels</span> <span class="o">=</span> <span class="p">[]</span>  <span class="c1"># type: List[Union[str, None]]</span>
        <span class="n">structure</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">structure</span>

        <span class="c1"># for both modes, include the Uniform mesh w/standard weights</span>
        <span class="n">grid</span> <span class="o">=</span> <span class="n">Kpoints</span><span class="o">.</span><span class="n">automatic_density_by_vol</span><span class="p">(</span><span class="n">structure</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">reciprocal_density</span><span class="p">)</span><span class="o">.</span><span class="n">kpts</span>
        <span class="n">ir_kpts</span> <span class="o">=</span> <span class="n">SpacegroupAnalyzer</span><span class="p">(</span><span class="n">structure</span><span class="p">,</span> <span class="n">symprec</span><span class="o">=</span><span class="mf">0.1</span><span class="p">)</span><span class="o">.</span><span class="n">get_ir_reciprocal_mesh</span><span class="p">(</span>
            <span class="n">grid</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
        <span class="p">)</span>
        <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">ir_kpts</span><span class="p">:</span>
            <span class="n">kpts</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">k</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
            <span class="n">weights</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="n">k</span><span class="p">[</span><span class="mi">1</span><span class="p">]))</span>
            <span class="n">all_labels</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="kc">None</span><span class="p">)</span>

        <span class="c1"># for both modes, include any user-added kpoints w/zero weight</span>
        <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">added_kpoints</span><span class="p">:</span>
            <span class="n">kpts</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">k</span><span class="p">)</span>
            <span class="n">weights</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="mf">0.0</span><span class="p">)</span>
            <span class="n">all_labels</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;user-defined&quot;</span><span class="p">)</span>

        <span class="c1"># for line mode only, add the symmetry lines w/zero weight</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">mode</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;line&quot;</span><span class="p">:</span>
            <span class="n">kpath</span> <span class="o">=</span> <span class="n">HighSymmKpath</span><span class="p">(</span><span class="n">structure</span><span class="p">)</span>
            <span class="n">frac_k_points</span><span class="p">,</span> <span class="n">labels</span> <span class="o">=</span> <span class="n">kpath</span><span class="o">.</span><span class="n">get_kpoints</span><span class="p">(</span>
                <span class="n">line_density</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">kpoints_line_density</span><span class="p">,</span> <span class="n">coords_are_cartesian</span><span class="o">=</span><span class="kc">False</span>
            <span class="p">)</span>

            <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">frac_k_points</span><span class="p">)):</span>
                <span class="n">kpts</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">frac_k_points</span><span class="p">[</span><span class="n">k</span><span class="p">])</span>
                <span class="n">weights</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="mf">0.0</span><span class="p">)</span>
                <span class="n">all_labels</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">labels</span><span class="p">[</span><span class="n">k</span><span class="p">])</span>

        <span class="n">comment</span> <span class="o">=</span> <span class="p">(</span>
            <span class="s2">&quot;HSE run along symmetry lines&quot;</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">mode</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;line&quot;</span>
            <span class="k">else</span> <span class="s2">&quot;HSE run on uniform grid&quot;</span>
        <span class="p">)</span>

        <span class="k">return</span> <span class="n">Kpoints</span><span class="p">(</span>
            <span class="n">comment</span><span class="o">=</span><span class="n">comment</span><span class="p">,</span>
            <span class="n">style</span><span class="o">=</span><span class="n">Kpoints</span><span class="o">.</span><span class="n">supported_modes</span><span class="o">.</span><span class="n">Reciprocal</span><span class="p">,</span>
            <span class="n">num_kpts</span><span class="o">=</span><span class="nb">len</span><span class="p">(</span><span class="n">kpts</span><span class="p">),</span>
            <span class="n">kpts</span><span class="o">=</span><span class="n">kpts</span><span class="p">,</span>
            <span class="n">kpts_weights</span><span class="o">=</span><span class="n">weights</span><span class="p">,</span>
            <span class="n">labels</span><span class="o">=</span><span class="n">all_labels</span><span class="p">,</span>
        <span class="p">)</span>

<div class="viewcode-block" id="MPHSEBSSet.override_from_prev_calc"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.MPHSEBSSet.override_from_prev_calc">[docs]</a>    <span class="k">def</span> <span class="nf">override_from_prev_calc</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prev_calc_dir</span><span class="o">=</span><span class="s2">&quot;.&quot;</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Update the input set to include settings from a previous calculation.</span>

<span class="sd">        Args:</span>
<span class="sd">            prev_calc_dir (str): The path to the previous calculation directory.</span>

<span class="sd">        Returns:</span>
<span class="sd">            The input set with the settings (structure, k-points, incar, etc)</span>
<span class="sd">            updated using the previous VASP run.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">vasprun</span><span class="p">,</span> <span class="n">outcar</span> <span class="o">=</span> <span class="n">get_vasprun_outcar</span><span class="p">(</span><span class="n">prev_calc_dir</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">_structure</span> <span class="o">=</span> <span class="n">get_structure_from_prev_run</span><span class="p">(</span><span class="n">vasprun</span><span class="p">,</span> <span class="n">outcar</span><span class="p">)</span>

        <span class="c1"># note: recommend not standardizing the cell because we want to retain</span>
        <span class="c1"># k-points</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">standardize</span><span class="p">:</span>
            <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span>
                <span class="s2">&quot;Use of standardize=True with from_prev_calc is not &quot;</span>
                <span class="s2">&quot;recommended as there is no guarantee the copied &quot;</span>
                <span class="s2">&quot;files will be appropriate for the standardized &quot;</span>
                <span class="s2">&quot;structure.&quot;</span>
            <span class="p">)</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">mode</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;gap&quot;</span><span class="p">:</span>
            <span class="n">added_kpoints</span> <span class="o">=</span> <span class="p">[]</span>

            <span class="n">bs</span> <span class="o">=</span> <span class="n">vasprun</span><span class="o">.</span><span class="n">get_band_structure</span><span class="p">()</span>
            <span class="n">vbm</span><span class="p">,</span> <span class="n">cbm</span> <span class="o">=</span> <span class="n">bs</span><span class="o">.</span><span class="n">get_vbm</span><span class="p">()[</span><span class="s2">&quot;kpoint&quot;</span><span class="p">],</span> <span class="n">bs</span><span class="o">.</span><span class="n">get_cbm</span><span class="p">()[</span><span class="s2">&quot;kpoint&quot;</span><span class="p">]</span>
            <span class="k">if</span> <span class="n">vbm</span><span class="p">:</span>
                <span class="n">added_kpoints</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">vbm</span><span class="o">.</span><span class="n">frac_coords</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">cbm</span><span class="p">:</span>
                <span class="n">added_kpoints</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">cbm</span><span class="o">.</span><span class="n">frac_coords</span><span class="p">)</span>

            <span class="bp">self</span><span class="o">.</span><span class="n">added_kpoints</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">added_kpoints</span><span class="p">)</span>

        <span class="n">files_to_transfer</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy_chgcar</span><span class="p">:</span>
            <span class="n">chgcars</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">glob</span><span class="o">.</span><span class="n">glob</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">Path</span><span class="p">(</span><span class="n">prev_calc_dir</span><span class="p">)</span> <span class="o">/</span> <span class="s2">&quot;CHGCAR*&quot;</span><span class="p">)))</span>
            <span class="k">if</span> <span class="n">chgcars</span><span class="p">:</span>
                <span class="n">files_to_transfer</span><span class="p">[</span><span class="s2">&quot;CHGCAR&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">chgcars</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">files_to_transfer</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">files_to_transfer</span><span class="p">)</span>

        <span class="k">return</span> <span class="bp">self</span></div>

<div class="viewcode-block" id="MPHSEBSSet.from_prev_calc"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.MPHSEBSSet.from_prev_calc">[docs]</a>    <span class="nd">@classmethod</span>
    <span class="k">def</span> <span class="nf">from_prev_calc</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">prev_calc_dir</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Generate a set of Vasp input files for HSE calculations from a</span>
<span class="sd">        directory of previous Vasp run.</span>

<span class="sd">        Args:</span>
<span class="sd">            prev_calc_dir (str): Directory containing the outputs</span>
<span class="sd">                (vasprun.xml and OUTCAR) of previous vasp run.</span>
<span class="sd">            **kwargs: All kwargs supported by MPHSEBSStaticSet, other than</span>
<span class="sd">                prev_structure which is determined from the previous calc dir.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">input_set</span> <span class="o">=</span> <span class="bp">cls</span><span class="p">(</span><span class="n">_dummy_structure</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">input_set</span><span class="o">.</span><span class="n">override_from_prev_calc</span><span class="p">(</span><span class="n">prev_calc_dir</span><span class="o">=</span><span class="n">prev_calc_dir</span><span class="p">)</span></div></div>


<div class="viewcode-block" id="MPNonSCFSet"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.MPNonSCFSet">[docs]</a><span class="k">class</span> <span class="nc">MPNonSCFSet</span><span class="p">(</span><span class="n">MPRelaxSet</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Init a MPNonSCFSet. Typically, you would use the classmethod</span>
<span class="sd">    from_prev_calc to initialize from a previous SCF run.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span>
            <span class="bp">self</span><span class="p">,</span>
            <span class="n">structure</span><span class="p">,</span>
            <span class="n">prev_incar</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
            <span class="n">mode</span><span class="o">=</span><span class="s2">&quot;line&quot;</span><span class="p">,</span>
            <span class="n">nedos</span><span class="o">=</span><span class="mi">2001</span><span class="p">,</span>
            <span class="n">dedos</span><span class="o">=</span><span class="mf">0.005</span><span class="p">,</span>
            <span class="n">reciprocal_density</span><span class="o">=</span><span class="mi">100</span><span class="p">,</span>
            <span class="n">sym_prec</span><span class="o">=</span><span class="mf">0.1</span><span class="p">,</span>
            <span class="n">kpoints_line_density</span><span class="o">=</span><span class="mi">20</span><span class="p">,</span>
            <span class="n">optics</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
            <span class="n">copy_chgcar</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
            <span class="n">nbands_factor</span><span class="o">=</span><span class="mf">1.2</span><span class="p">,</span>
            <span class="n">small_gap_multiply</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
            <span class="o">**</span><span class="n">kwargs</span>
    <span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            structure (Structure): Structure to compute</span>
<span class="sd">            prev_incar (Incar/string): Incar file from previous run.</span>
<span class="sd">            mode (str): Line, Uniform or Boltztrap mode supported.</span>
<span class="sd">            nedos (int): nedos parameter. Default to 2001.</span>
<span class="sd">            dedos (float): setting nedos=0 and uniform mode in from_prev_calc,</span>
<span class="sd">                an automatic nedos will be calculated using the total energy range</span>
<span class="sd">                divided by the energy step dedos</span>
<span class="sd">            reciprocal_density (int): density of k-mesh by reciprocal</span>
<span class="sd">                volume (defaults to 100)</span>
<span class="sd">            sym_prec (float): Symmetry precision (for Uniform mode).</span>
<span class="sd">            kpoints_line_density (int): Line density for Line mode.</span>
<span class="sd">            optics (bool): whether to add dielectric function</span>
<span class="sd">            copy_chgcar: Whether to copy the old CHGCAR when starting from a</span>
<span class="sd">                previous calculation.</span>
<span class="sd">            nbands_factor (float): Multiplicative factor for NBANDS when starting</span>
<span class="sd">                from a previous calculation. Choose a higher number if you are</span>
<span class="sd">                doing an LOPTICS calculation.</span>
<span class="sd">            small_gap_multiply ([float, float]): When starting from a previous</span>
<span class="sd">                calculation, if the gap is less than 1st index, multiply the default</span>
<span class="sd">                reciprocal_density by the 2nd index.</span>
<span class="sd">            **kwargs: kwargs supported by MPRelaxSet.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">structure</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">prev_incar</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span>
            <span class="n">prev_incar</span> <span class="o">=</span> <span class="n">Incar</span><span class="o">.</span><span class="n">from_file</span><span class="p">(</span><span class="n">prev_incar</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">prev_incar</span> <span class="o">=</span> <span class="n">prev_incar</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">kwargs</span> <span class="o">=</span> <span class="n">kwargs</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">nedos</span> <span class="o">=</span> <span class="n">nedos</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">dedos</span> <span class="o">=</span> <span class="n">dedos</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">reciprocal_density</span> <span class="o">=</span> <span class="n">reciprocal_density</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">sym_prec</span> <span class="o">=</span> <span class="n">sym_prec</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">kpoints_line_density</span> <span class="o">=</span> <span class="n">kpoints_line_density</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">optics</span> <span class="o">=</span> <span class="n">optics</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">mode</span> <span class="o">=</span> <span class="n">mode</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">copy_chgcar</span> <span class="o">=</span> <span class="n">copy_chgcar</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">nbands_factor</span> <span class="o">=</span> <span class="n">nbands_factor</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">small_gap_multiply</span> <span class="o">=</span> <span class="n">small_gap_multiply</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">mode</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;line&quot;</span><span class="p">,</span> <span class="s2">&quot;uniform&quot;</span><span class="p">,</span> <span class="s2">&quot;boltztrap&quot;</span><span class="p">]:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;Supported modes for NonSCF runs are &#39;Line&#39;, &quot;</span>
                <span class="s2">&quot;&#39;Uniform&#39; and &#39;Boltztrap!&quot;</span>
            <span class="p">)</span>

        <span class="k">if</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">mode</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">!=</span> <span class="s2">&quot;uniform&quot;</span> <span class="ow">or</span> <span class="n">nedos</span> <span class="o">&lt;</span> <span class="mi">2000</span><span class="p">)</span> <span class="ow">and</span> <span class="n">optics</span><span class="p">:</span>
            <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span>
                <span class="s2">&quot;It is recommended to use Uniform mode with a high &quot;</span>
                <span class="s2">&quot;NEDOS for optics calculations.&quot;</span>
            <span class="p">)</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">incar</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Incar</span><span class="p">:</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :return: Incar</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">incar</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">incar</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">prev_incar</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">incar</span><span class="o">.</span><span class="n">update</span><span class="p">({</span><span class="n">k</span><span class="p">:</span> <span class="n">v</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">prev_incar</span><span class="o">.</span><span class="n">items</span><span class="p">()})</span>

        <span class="c1"># Overwrite necessary INCAR parameters from previous runs</span>
        <span class="n">incar</span><span class="o">.</span><span class="n">update</span><span class="p">(</span>
            <span class="p">{</span>
                <span class="s2">&quot;IBRION&quot;</span><span class="p">:</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span>
                <span class="s2">&quot;LCHARG&quot;</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span>
                <span class="s2">&quot;LORBIT&quot;</span><span class="p">:</span> <span class="mi">11</span><span class="p">,</span>
                <span class="s2">&quot;LWAVE&quot;</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span>
                <span class="s2">&quot;NSW&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
                <span class="s2">&quot;ISYM&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
                <span class="s2">&quot;ICHARG&quot;</span><span class="p">:</span> <span class="mi">11</span><span class="p">,</span>
            <span class="p">}</span>
        <span class="p">)</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">mode</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;uniform&quot;</span><span class="p">:</span>
            <span class="c1"># use tetrahedron method for DOS and optics calculations</span>
            <span class="n">incar</span><span class="o">.</span><span class="n">update</span><span class="p">({</span><span class="s2">&quot;ISMEAR&quot;</span><span class="p">:</span> <span class="o">-</span><span class="mi">5</span><span class="p">,</span> <span class="s2">&quot;ISYM&quot;</span><span class="p">:</span> <span class="mi">2</span><span class="p">})</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="c1"># if line mode, can&#39;t use ISMEAR=-5; also use small sigma to avoid</span>
            <span class="c1"># partial occupancies for small band gap materials.</span>
            <span class="c1"># finally, explicit k-point generation (needed for bolztrap mode)</span>
            <span class="c1"># is incompatible with ISMEAR = -5.</span>
            <span class="n">incar</span><span class="o">.</span><span class="n">update</span><span class="p">({</span><span class="s2">&quot;ISMEAR&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="s2">&quot;SIGMA&quot;</span><span class="p">:</span> <span class="mf">0.01</span><span class="p">})</span>

        <span class="n">incar</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;user_incar_settings&quot;</span><span class="p">,</span> <span class="p">{}))</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">mode</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="ow">in</span> <span class="s2">&quot;uniform&quot;</span><span class="p">:</span>
            <span class="c1"># Set smaller steps for DOS and optics output</span>
            <span class="n">incar</span><span class="p">[</span><span class="s2">&quot;NEDOS&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">nedos</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">optics</span><span class="p">:</span>
            <span class="n">incar</span><span class="p">[</span><span class="s2">&quot;LOPTICS&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>

        <span class="n">incar</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">&quot;MAGMOM&quot;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>

        <span class="k">return</span> <span class="n">incar</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">kpoints</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Optional</span><span class="p">[</span><span class="n">Kpoints</span><span class="p">]:</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :return: Kpoints</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="c1"># override pymatgen kpoints if provided</span>
        <span class="n">user_kpoints</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;user_kpoints_settings&quot;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">user_kpoints</span><span class="p">,</span> <span class="n">Kpoints</span><span class="p">):</span>
            <span class="k">return</span> <span class="n">user_kpoints</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">mode</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;line&quot;</span><span class="p">:</span>
            <span class="n">kpath</span> <span class="o">=</span> <span class="n">HighSymmKpath</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">structure</span><span class="p">)</span>
            <span class="n">frac_k_points</span><span class="p">,</span> <span class="n">k_points_labels</span> <span class="o">=</span> <span class="n">kpath</span><span class="o">.</span><span class="n">get_kpoints</span><span class="p">(</span>
                <span class="n">line_density</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">kpoints_line_density</span><span class="p">,</span> <span class="n">coords_are_cartesian</span><span class="o">=</span><span class="kc">False</span>
            <span class="p">)</span>
            <span class="n">kpoints</span> <span class="o">=</span> <span class="n">Kpoints</span><span class="p">(</span>
                <span class="n">comment</span><span class="o">=</span><span class="s2">&quot;Non SCF run along symmetry lines&quot;</span><span class="p">,</span>
                <span class="n">style</span><span class="o">=</span><span class="n">Kpoints</span><span class="o">.</span><span class="n">supported_modes</span><span class="o">.</span><span class="n">Reciprocal</span><span class="p">,</span>
                <span class="n">num_kpts</span><span class="o">=</span><span class="nb">len</span><span class="p">(</span><span class="n">frac_k_points</span><span class="p">),</span>
                <span class="n">kpts</span><span class="o">=</span><span class="n">frac_k_points</span><span class="p">,</span>
                <span class="n">labels</span><span class="o">=</span><span class="n">k_points_labels</span><span class="p">,</span>
                <span class="n">kpts_weights</span><span class="o">=</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="n">frac_k_points</span><span class="p">),</span>
            <span class="p">)</span>
        <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">mode</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;boltztrap&quot;</span><span class="p">:</span>
            <span class="n">kpoints</span> <span class="o">=</span> <span class="n">Kpoints</span><span class="o">.</span><span class="n">automatic_density_by_vol</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">structure</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">reciprocal_density</span>
            <span class="p">)</span>
            <span class="n">mesh</span> <span class="o">=</span> <span class="n">kpoints</span><span class="o">.</span><span class="n">kpts</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
            <span class="n">ir_kpts</span> <span class="o">=</span> <span class="n">SpacegroupAnalyzer</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">structure</span><span class="p">,</span> <span class="n">symprec</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">sym_prec</span>
            <span class="p">)</span><span class="o">.</span><span class="n">get_ir_reciprocal_mesh</span><span class="p">(</span><span class="n">mesh</span><span class="p">)</span>
            <span class="n">kpts</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="n">weights</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">ir_kpts</span><span class="p">:</span>
                <span class="n">kpts</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">k</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
                <span class="n">weights</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="n">k</span><span class="p">[</span><span class="mi">1</span><span class="p">]))</span>
            <span class="n">kpoints</span> <span class="o">=</span> <span class="n">Kpoints</span><span class="p">(</span>
                <span class="n">comment</span><span class="o">=</span><span class="s2">&quot;Non SCF run on uniform grid&quot;</span><span class="p">,</span>
                <span class="n">style</span><span class="o">=</span><span class="n">Kpoints</span><span class="o">.</span><span class="n">supported_modes</span><span class="o">.</span><span class="n">Reciprocal</span><span class="p">,</span>
                <span class="n">num_kpts</span><span class="o">=</span><span class="nb">len</span><span class="p">(</span><span class="n">ir_kpts</span><span class="p">),</span>
                <span class="n">kpts</span><span class="o">=</span><span class="n">kpts</span><span class="p">,</span>
                <span class="n">kpts_weights</span><span class="o">=</span><span class="n">weights</span><span class="p">,</span>
            <span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_config_dict</span><span class="p">[</span><span class="s2">&quot;KPOINTS&quot;</span><span class="p">][</span><span class="s2">&quot;reciprocal_density&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">reciprocal_density</span>
            <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">kpoints</span>

        <span class="k">return</span> <span class="n">kpoints</span>

<div class="viewcode-block" id="MPNonSCFSet.override_from_prev_calc"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.MPNonSCFSet.override_from_prev_calc">[docs]</a>    <span class="k">def</span> <span class="nf">override_from_prev_calc</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prev_calc_dir</span><span class="o">=</span><span class="s2">&quot;.&quot;</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Update the input set to include settings from a previous calculation.</span>

<span class="sd">        Args:</span>
<span class="sd">            prev_calc_dir (str): The path to the previous calculation directory.</span>

<span class="sd">        Returns:</span>
<span class="sd">            The input set with the settings (structure, k-points, incar, etc)</span>
<span class="sd">            updated using the previous VASP run.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">vasprun</span><span class="p">,</span> <span class="n">outcar</span> <span class="o">=</span> <span class="n">get_vasprun_outcar</span><span class="p">(</span><span class="n">prev_calc_dir</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">prev_incar</span> <span class="o">=</span> <span class="n">vasprun</span><span class="o">.</span><span class="n">incar</span>

        <span class="c1"># Get a Magmom-decorated structure</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_structure</span> <span class="o">=</span> <span class="n">get_structure_from_prev_run</span><span class="p">(</span><span class="n">vasprun</span><span class="p">,</span> <span class="n">outcar</span><span class="p">)</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">standardize</span><span class="p">:</span>
            <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span>
                <span class="s2">&quot;Use of standardize=True with from_prev_run is not &quot;</span>
                <span class="s2">&quot;recommended as there is no guarantee the copied &quot;</span>
                <span class="s2">&quot;files will be appropriate for the standardized&quot;</span>
                <span class="s2">&quot; structure. copy_chgcar is enforced to be false.&quot;</span>
            <span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">copy_chgcar</span> <span class="o">=</span> <span class="kc">False</span>

        <span class="c1"># Turn off spin when magmom for every site is smaller than 0.02.</span>
        <span class="k">if</span> <span class="n">outcar</span> <span class="ow">and</span> <span class="n">outcar</span><span class="o">.</span><span class="n">magnetization</span><span class="p">:</span>
            <span class="n">site_magmom</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">i</span><span class="p">[</span><span class="s2">&quot;tot&quot;</span><span class="p">]</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">outcar</span><span class="o">.</span><span class="n">magnetization</span><span class="p">])</span>
            <span class="n">ispin</span> <span class="o">=</span> <span class="mi">2</span> <span class="k">if</span> <span class="n">np</span><span class="o">.</span><span class="n">any</span><span class="p">(</span><span class="n">site_magmom</span><span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">abs</span><span class="p">(</span><span class="n">site_magmom</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mf">0.02</span><span class="p">])</span> <span class="k">else</span> <span class="mi">1</span>

        <span class="k">elif</span> <span class="n">vasprun</span><span class="o">.</span><span class="n">is_spin</span><span class="p">:</span>
            <span class="n">ispin</span> <span class="o">=</span> <span class="mi">2</span>

        <span class="k">else</span><span class="p">:</span>
            <span class="n">ispin</span> <span class="o">=</span> <span class="mi">1</span>

        <span class="n">nbands</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">ceil</span><span class="p">(</span><span class="n">vasprun</span><span class="o">.</span><span class="n">parameters</span><span class="p">[</span><span class="s2">&quot;NBANDS&quot;</span><span class="p">]</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">nbands_factor</span><span class="p">))</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">prev_incar</span><span class="o">.</span><span class="n">update</span><span class="p">({</span><span class="s2">&quot;ISPIN&quot;</span><span class="p">:</span> <span class="n">ispin</span><span class="p">,</span> <span class="s2">&quot;NBANDS&quot;</span><span class="p">:</span> <span class="n">nbands</span><span class="p">})</span>

        <span class="n">files_to_transfer</span> <span class="o">=</span> <span class="p">{}</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy_chgcar</span><span class="p">:</span>
            <span class="n">chgcars</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">glob</span><span class="o">.</span><span class="n">glob</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">Path</span><span class="p">(</span><span class="n">prev_calc_dir</span><span class="p">)</span> <span class="o">/</span> <span class="s2">&quot;CHGCAR*&quot;</span><span class="p">)))</span>
            <span class="k">if</span> <span class="n">chgcars</span><span class="p">:</span>
                <span class="n">files_to_transfer</span><span class="p">[</span><span class="s2">&quot;CHGCAR&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">chgcars</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">files_to_transfer</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">files_to_transfer</span><span class="p">)</span>

        <span class="c1"># multiply the reciprocal density if needed:</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">small_gap_multiply</span><span class="p">:</span>
            <span class="n">gap</span> <span class="o">=</span> <span class="n">vasprun</span><span class="o">.</span><span class="n">eigenvalue_band_properties</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
            <span class="k">if</span> <span class="n">gap</span> <span class="o">&lt;=</span> <span class="bp">self</span><span class="o">.</span><span class="n">small_gap_multiply</span><span class="p">[</span><span class="mi">0</span><span class="p">]:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">reciprocal_density</span> <span class="o">=</span> <span class="p">(</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">reciprocal_density</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">small_gap_multiply</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
                <span class="p">)</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">kpoints_line_density</span> <span class="o">=</span> <span class="p">(</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">kpoints_line_density</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">small_gap_multiply</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
                <span class="p">)</span>

        <span class="c1"># automatic setting of nedos using the total energy range and the energy step dedos</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">nedos</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
            <span class="n">emax</span> <span class="o">=</span> <span class="nb">max</span><span class="p">([</span><span class="n">eigs</span><span class="o">.</span><span class="n">max</span><span class="p">()</span> <span class="k">for</span> <span class="n">eigs</span> <span class="ow">in</span> <span class="n">vasprun</span><span class="o">.</span><span class="n">eigenvalues</span><span class="o">.</span><span class="n">values</span><span class="p">()])</span>
            <span class="n">emin</span> <span class="o">=</span> <span class="nb">min</span><span class="p">([</span><span class="n">eigs</span><span class="o">.</span><span class="n">min</span><span class="p">()</span> <span class="k">for</span> <span class="n">eigs</span> <span class="ow">in</span> <span class="n">vasprun</span><span class="o">.</span><span class="n">eigenvalues</span><span class="o">.</span><span class="n">values</span><span class="p">()])</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">nedos</span> <span class="o">=</span> <span class="nb">int</span><span class="p">((</span><span class="n">emax</span> <span class="o">-</span> <span class="n">emin</span><span class="p">)</span> <span class="o">/</span> <span class="bp">self</span><span class="o">.</span><span class="n">dedos</span><span class="p">)</span>

        <span class="k">return</span> <span class="bp">self</span></div>

<div class="viewcode-block" id="MPNonSCFSet.from_prev_calc"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.MPNonSCFSet.from_prev_calc">[docs]</a>    <span class="nd">@classmethod</span>
    <span class="k">def</span> <span class="nf">from_prev_calc</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">prev_calc_dir</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Generate a set of Vasp input files for NonSCF calculations from a</span>
<span class="sd">        directory of previous static Vasp run.</span>

<span class="sd">        Args:</span>
<span class="sd">            prev_calc_dir (str): The directory contains the outputs(</span>
<span class="sd">                vasprun.xml and OUTCAR) of previous vasp run.</span>
<span class="sd">            **kwargs: All kwargs supported by MPNonSCFSet, other than structure,</span>
<span class="sd">                prev_incar and prev_chgcar which are determined from the</span>
<span class="sd">                prev_calc_dir.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">input_set</span> <span class="o">=</span> <span class="bp">cls</span><span class="p">(</span><span class="n">_dummy_structure</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">input_set</span><span class="o">.</span><span class="n">override_from_prev_calc</span><span class="p">(</span><span class="n">prev_calc_dir</span><span class="o">=</span><span class="n">prev_calc_dir</span><span class="p">)</span></div></div>


<div class="viewcode-block" id="MPSOCSet"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.MPSOCSet">[docs]</a><span class="k">class</span> <span class="nc">MPSOCSet</span><span class="p">(</span><span class="n">MPStaticSet</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    An input set for running spin-orbit coupling (SOC) calculations.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span>
            <span class="bp">self</span><span class="p">,</span>
            <span class="n">structure</span><span class="p">,</span>
            <span class="n">saxis</span><span class="o">=</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span>
            <span class="n">copy_chgcar</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
            <span class="n">nbands_factor</span><span class="o">=</span><span class="mf">1.2</span><span class="p">,</span>
            <span class="n">reciprocal_density</span><span class="o">=</span><span class="mi">100</span><span class="p">,</span>
            <span class="n">small_gap_multiply</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
            <span class="n">magmom</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
            <span class="o">**</span><span class="n">kwargs</span>
    <span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            structure (Structure): the structure must have the &#39;magmom&#39; site</span>
<span class="sd">                property and each magnetic moment value must have 3</span>
<span class="sd">                components. eg: ``magmom = [[0,0,2], ...]``</span>
<span class="sd">            saxis (tuple): magnetic moment orientation</span>
<span class="sd">            copy_chgcar: Whether to copy the old CHGCAR. Defaults to True.</span>
<span class="sd">            nbands_factor (float): Multiplicative factor for NBANDS. Choose a</span>
<span class="sd">                higher number if you are doing an LOPTICS calculation.</span>
<span class="sd">            reciprocal_density (int): density of k-mesh by reciprocal volume.</span>
<span class="sd">            small_gap_multiply ([float, float]): If the gap is less than</span>
<span class="sd">                1st index, multiply the default reciprocal_density by the 2nd</span>
<span class="sd">                index.</span>
<span class="sd">            magmom (list[list[float]]): Override for the structure magmoms.</span>
<span class="sd">            **kwargs: kwargs supported by MPStaticSet.</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">structure</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="s2">&quot;magmom&quot;</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span>
                <span class="n">structure</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">magmom</span><span class="p">,</span> <span class="nb">list</span>
        <span class="p">):</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;The structure must have the &#39;magmom&#39; site &quot;</span>
                <span class="s2">&quot;property and each magnetic moment value must have 3 &quot;</span>
                <span class="s2">&quot;components. eg:- magmom = [0,0,2]&quot;</span>
            <span class="p">)</span>

        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">structure</span><span class="p">,</span> <span class="n">reciprocal_density</span><span class="o">=</span><span class="n">reciprocal_density</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">saxis</span> <span class="o">=</span> <span class="n">saxis</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">copy_chgcar</span> <span class="o">=</span> <span class="n">copy_chgcar</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">nbands_factor</span> <span class="o">=</span> <span class="n">nbands_factor</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">small_gap_multiply</span> <span class="o">=</span> <span class="n">small_gap_multiply</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">magmom</span> <span class="o">=</span> <span class="n">magmom</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">incar</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Incar</span><span class="p">:</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :return: Incar</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">incar</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">incar</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">prev_incar</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">incar</span><span class="o">.</span><span class="n">update</span><span class="p">({</span><span class="n">k</span><span class="p">:</span> <span class="n">v</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">prev_incar</span><span class="o">.</span><span class="n">items</span><span class="p">()})</span>

        <span class="c1"># Overwrite necessary INCAR parameters from previous runs</span>
        <span class="n">incar</span><span class="o">.</span><span class="n">update</span><span class="p">(</span>
            <span class="p">{</span><span class="s2">&quot;ISYM&quot;</span><span class="p">:</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="s2">&quot;LSORBIT&quot;</span><span class="p">:</span> <span class="s2">&quot;T&quot;</span><span class="p">,</span> <span class="s2">&quot;ICHARG&quot;</span><span class="p">:</span> <span class="mi">11</span><span class="p">,</span> <span class="s2">&quot;SAXIS&quot;</span><span class="p">:</span> <span class="nb">list</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">saxis</span><span class="p">)}</span>
        <span class="p">)</span>
        <span class="n">incar</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;user_incar_settings&quot;</span><span class="p">,</span> <span class="p">{}))</span>

        <span class="k">return</span> <span class="n">incar</span>

<div class="viewcode-block" id="MPSOCSet.override_from_prev_calc"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.MPSOCSet.override_from_prev_calc">[docs]</a>    <span class="k">def</span> <span class="nf">override_from_prev_calc</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prev_calc_dir</span><span class="o">=</span><span class="s2">&quot;.&quot;</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Update the input set to include settings from a previous calculation.</span>

<span class="sd">        Args:</span>
<span class="sd">            prev_calc_dir (str): The path to the previous calculation directory.</span>

<span class="sd">        Returns:</span>
<span class="sd">            The input set with the settings (structure, k-points, incar, etc)</span>
<span class="sd">            updated using the previous VASP run.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">vasprun</span><span class="p">,</span> <span class="n">outcar</span> <span class="o">=</span> <span class="n">get_vasprun_outcar</span><span class="p">(</span><span class="n">prev_calc_dir</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">prev_incar</span> <span class="o">=</span> <span class="n">vasprun</span><span class="o">.</span><span class="n">incar</span>

        <span class="c1"># Remove magmoms from previous INCAR, since we will prefer</span>
        <span class="c1"># the final calculated magmoms</span>
        <span class="c1"># TODO: revisit in context of MPStaticSet incar logic</span>
        <span class="k">if</span> <span class="s2">&quot;MAGMOM&quot;</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">prev_incar</span><span class="p">:</span>
            <span class="k">del</span> <span class="bp">self</span><span class="o">.</span><span class="n">prev_incar</span><span class="p">[</span><span class="s2">&quot;magmom&quot;</span><span class="p">]</span>

        <span class="c1"># Get a magmom-decorated structure</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_structure</span> <span class="o">=</span> <span class="n">get_structure_from_prev_run</span><span class="p">(</span><span class="n">vasprun</span><span class="p">,</span> <span class="n">outcar</span><span class="p">)</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">standardize</span><span class="p">:</span>
            <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span>
                <span class="s2">&quot;Use of standardize=True with from_prev_run is not &quot;</span>
                <span class="s2">&quot;recommended as there is no guarantee the copied &quot;</span>
                <span class="s2">&quot;files will be appropriate for the standardized&quot;</span>
                <span class="s2">&quot; structure. copy_chgcar is enforced to be false.&quot;</span>
            <span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">copy_chgcar</span> <span class="o">=</span> <span class="kc">False</span>

        <span class="c1"># override magmom if provided</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">magmom</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_structure</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_structure</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span>
                <span class="n">site_properties</span><span class="o">=</span><span class="p">{</span><span class="s2">&quot;magmom&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">magmom</span><span class="p">}</span>
            <span class="p">)</span>

        <span class="c1"># magmom has to be 3D for SOC calculation.</span>
        <span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_structure</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="s2">&quot;magmom&quot;</span><span class="p">):</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_structure</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">magmom</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">_structure</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_structure</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span>
                    <span class="n">site_properties</span><span class="o">=</span><span class="p">{</span>
                        <span class="s2">&quot;magmom&quot;</span><span class="p">:</span> <span class="p">[[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">site</span><span class="o">.</span><span class="n">magmom</span><span class="p">]</span> <span class="k">for</span> <span class="n">site</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_structure</span><span class="p">]</span>
                    <span class="p">}</span>
                <span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;Neither the previous structure has magmom &quot;</span>
                <span class="s2">&quot;property nor magmom provided&quot;</span>
            <span class="p">)</span>

        <span class="n">nbands</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">ceil</span><span class="p">(</span><span class="n">vasprun</span><span class="o">.</span><span class="n">parameters</span><span class="p">[</span><span class="s2">&quot;NBANDS&quot;</span><span class="p">]</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">nbands_factor</span><span class="p">))</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">prev_incar</span><span class="o">.</span><span class="n">update</span><span class="p">({</span><span class="s2">&quot;NBANDS&quot;</span><span class="p">:</span> <span class="n">nbands</span><span class="p">})</span>

        <span class="n">files_to_transfer</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy_chgcar</span><span class="p">:</span>
            <span class="n">chgcars</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">glob</span><span class="o">.</span><span class="n">glob</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">Path</span><span class="p">(</span><span class="n">prev_calc_dir</span><span class="p">)</span> <span class="o">/</span> <span class="s2">&quot;CHGCAR*&quot;</span><span class="p">)))</span>
            <span class="k">if</span> <span class="n">chgcars</span><span class="p">:</span>
                <span class="n">files_to_transfer</span><span class="p">[</span><span class="s2">&quot;CHGCAR&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">chgcars</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">files_to_transfer</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">files_to_transfer</span><span class="p">)</span>

        <span class="c1"># multiply the reciprocal density if needed:</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">small_gap_multiply</span><span class="p">:</span>
            <span class="n">gap</span> <span class="o">=</span> <span class="n">vasprun</span><span class="o">.</span><span class="n">eigenvalue_band_properties</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
            <span class="k">if</span> <span class="n">gap</span> <span class="o">&lt;=</span> <span class="bp">self</span><span class="o">.</span><span class="n">small_gap_multiply</span><span class="p">[</span><span class="mi">0</span><span class="p">]:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">reciprocal_density</span> <span class="o">=</span> <span class="p">(</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">reciprocal_density</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">small_gap_multiply</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
                <span class="p">)</span>

        <span class="k">return</span> <span class="bp">self</span></div>

<div class="viewcode-block" id="MPSOCSet.from_prev_calc"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.MPSOCSet.from_prev_calc">[docs]</a>    <span class="nd">@classmethod</span>
    <span class="k">def</span> <span class="nf">from_prev_calc</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">prev_calc_dir</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Generate a set of Vasp input files for SOC calculations from a</span>
<span class="sd">        directory of previous static Vasp run. SOC calc requires all 3</span>
<span class="sd">        components for MAGMOM for each atom in the structure.</span>

<span class="sd">        Args:</span>
<span class="sd">            prev_calc_dir (str): The directory contains the outputs(</span>
<span class="sd">                vasprun.xml and OUTCAR) of previous vasp run.</span>
<span class="sd">            **kwargs: All kwargs supported by MPSOCSet, other than structure,</span>
<span class="sd">                prev_incar and prev_chgcar which are determined from the</span>
<span class="sd">                prev_calc_dir.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">input_set</span> <span class="o">=</span> <span class="bp">cls</span><span class="p">(</span><span class="n">_dummy_structure</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">input_set</span><span class="o">.</span><span class="n">override_from_prev_calc</span><span class="p">(</span><span class="n">prev_calc_dir</span><span class="o">=</span><span class="n">prev_calc_dir</span><span class="p">)</span></div></div>


<div class="viewcode-block" id="MPNMRSet"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.MPNMRSet">[docs]</a><span class="k">class</span> <span class="nc">MPNMRSet</span><span class="p">(</span><span class="n">MPStaticSet</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Init a MPNMRSet.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span>
            <span class="bp">self</span><span class="p">,</span>
            <span class="n">structure</span><span class="p">,</span>
            <span class="n">mode</span><span class="o">=</span><span class="s2">&quot;cs&quot;</span><span class="p">,</span>
            <span class="n">isotopes</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
            <span class="n">prev_incar</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
            <span class="n">reciprocal_density</span><span class="o">=</span><span class="mi">100</span><span class="p">,</span>
            <span class="o">**</span><span class="n">kwargs</span>
    <span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            structure (Structure): Structure to compute</span>
<span class="sd">            mode (str): The NMR calculation to run</span>
<span class="sd">                            &quot;cs&quot;: for Chemical Shift</span>
<span class="sd">                            &quot;efg&quot; for Electric Field Gradient</span>
<span class="sd">            isotopes (list): list of Isotopes for quadrupole moments</span>
<span class="sd">            prev_incar (Incar): Incar file from previous run.</span>
<span class="sd">            reciprocal_density (int): density of k-mesh by reciprocal</span>
<span class="sd">                                    volume (defaults to 100)</span>
<span class="sd">            **kwargs: kwargs supported by MPStaticSet.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">mode</span> <span class="o">=</span> <span class="n">mode</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">isotopes</span> <span class="o">=</span> <span class="n">isotopes</span> <span class="k">if</span> <span class="n">isotopes</span> <span class="k">else</span> <span class="p">[]</span>
        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span>
            <span class="n">structure</span><span class="p">,</span>
            <span class="n">prev_incar</span><span class="o">=</span><span class="n">prev_incar</span><span class="p">,</span>
            <span class="n">reciprocal_density</span><span class="o">=</span><span class="n">reciprocal_density</span><span class="p">,</span>
            <span class="o">**</span><span class="n">kwargs</span>
        <span class="p">)</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">incar</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :return: Incar</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">incar</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">incar</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">mode</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;cs&quot;</span><span class="p">:</span>
            <span class="n">incar</span><span class="o">.</span><span class="n">update</span><span class="p">(</span>
                <span class="p">{</span>
                    <span class="s2">&quot;LCHIMAG&quot;</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span>
                    <span class="s2">&quot;EDIFF&quot;</span><span class="p">:</span> <span class="o">-</span><span class="mf">1.0e-10</span><span class="p">,</span>
                    <span class="s2">&quot;ISYM&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
                    <span class="s2">&quot;LCHARG&quot;</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span>
                    <span class="s2">&quot;LNMR_SYM_RED&quot;</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span>
                    <span class="s2">&quot;NELMIN&quot;</span><span class="p">:</span> <span class="mi">10</span><span class="p">,</span>
                    <span class="s2">&quot;NSLPLINE&quot;</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span>
                    <span class="s2">&quot;PREC&quot;</span><span class="p">:</span> <span class="s2">&quot;ACCURATE&quot;</span><span class="p">,</span>
                    <span class="s2">&quot;SIGMA&quot;</span><span class="p">:</span> <span class="mf">0.01</span><span class="p">,</span>
                <span class="p">}</span>
            <span class="p">)</span>
        <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">mode</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;efg&quot;</span><span class="p">:</span>

            <span class="n">isotopes</span> <span class="o">=</span> <span class="p">{</span><span class="n">ist</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;-&quot;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]:</span> <span class="n">ist</span> <span class="k">for</span> <span class="n">ist</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">isotopes</span><span class="p">}</span>

            <span class="n">quad_efg</span> <span class="o">=</span> <span class="p">[</span>
                <span class="n">Specie</span><span class="p">(</span><span class="n">p</span><span class="p">)</span><span class="o">.</span><span class="n">get_nmr_quadrupole_moment</span><span class="p">(</span><span class="n">isotopes</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="kc">None</span><span class="p">))</span>
                <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">poscar</span><span class="o">.</span><span class="n">site_symbols</span>
            <span class="p">]</span>

            <span class="n">incar</span><span class="o">.</span><span class="n">update</span><span class="p">(</span>
                <span class="p">{</span>
                    <span class="s2">&quot;ALGO&quot;</span><span class="p">:</span> <span class="s2">&quot;FAST&quot;</span><span class="p">,</span>
                    <span class="s2">&quot;EDIFF&quot;</span><span class="p">:</span> <span class="o">-</span><span class="mf">1.0e-10</span><span class="p">,</span>
                    <span class="s2">&quot;ISYM&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
                    <span class="s2">&quot;LCHARG&quot;</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span>
                    <span class="s2">&quot;LEFG&quot;</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span>
                    <span class="s2">&quot;QUAD_EFG&quot;</span><span class="p">:</span> <span class="n">quad_efg</span><span class="p">,</span>
                    <span class="s2">&quot;NELMIN&quot;</span><span class="p">:</span> <span class="mi">10</span><span class="p">,</span>
                    <span class="s2">&quot;PREC&quot;</span><span class="p">:</span> <span class="s2">&quot;ACCURATE&quot;</span><span class="p">,</span>
                    <span class="s2">&quot;SIGMA&quot;</span><span class="p">:</span> <span class="mf">0.01</span><span class="p">,</span>
                <span class="p">}</span>
            <span class="p">)</span>
        <span class="n">incar</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;user_incar_settings&quot;</span><span class="p">,</span> <span class="p">{}))</span>

        <span class="k">return</span> <span class="n">incar</span></div>


<div class="viewcode-block" id="MVLElasticSet"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.MVLElasticSet">[docs]</a><span class="k">class</span> <span class="nc">MVLElasticSet</span><span class="p">(</span><span class="n">MPRelaxSet</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    MVL denotes VASP input sets that are implemented by the Materials Virtual</span>
<span class="sd">    Lab (http://www.materialsvirtuallab.org) for various research.</span>

<span class="sd">    This input set is used to calculate elastic constants in VASP. It is used</span>
<span class="sd">    in the following work::</span>

<span class="sd">        Z. Deng, Z. Wang, I.-H. Chu, J. Luo, S. P. Ong.</span>
<span class="sd">        “Elastic Properties of Alkali Superionic Conductor Electrolytes</span>
<span class="sd">        from First Principles Calculations”, J. Electrochem. Soc.</span>
<span class="sd">        2016, 163(2), A67-A74. doi: 10.1149/2.0061602jes</span>

<span class="sd">    To read the elastic constants, you may use the Outcar class which parses the</span>
<span class="sd">    elastic constants.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">structure</span><span class="p">,</span> <span class="n">potim</span><span class="o">=</span><span class="mf">0.015</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            scale (float): POTIM parameter. The default of 0.015 is usually fine,</span>
<span class="sd">                but some structures may require a smaller step.</span>
<span class="sd">            user_incar_settings (dict): A dict specifying additional incar</span>
<span class="sd">                settings.</span>
<span class="sd">            kwargs:</span>
<span class="sd">                Parameters supported by MPRelaxSet.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">structure</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_config_dict</span><span class="p">[</span><span class="s2">&quot;INCAR&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">update</span><span class="p">({</span><span class="s2">&quot;IBRION&quot;</span><span class="p">:</span> <span class="mi">6</span><span class="p">,</span> <span class="s2">&quot;NFREE&quot;</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span> <span class="s2">&quot;POTIM&quot;</span><span class="p">:</span> <span class="n">potim</span><span class="p">})</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_config_dict</span><span class="p">[</span><span class="s2">&quot;INCAR&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">&quot;NPAR&quot;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span></div>


<div class="viewcode-block" id="MVLGWSet"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.MVLGWSet">[docs]</a><span class="k">class</span> <span class="nc">MVLGWSet</span><span class="p">(</span><span class="n">DictSet</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    MVL denotes VASP input sets that are implemented by the Materials Virtual</span>
<span class="sd">    Lab (http://www.materialsvirtuallab.org) for various research. This is a</span>
<span class="sd">    flexible input set for GW calculations.</span>

<span class="sd">    Note that unlike all other input sets in this module, the PBE_54 series of</span>
<span class="sd">    functional is set as the default. These have much improved performance for</span>
<span class="sd">    GW calculations.</span>

<span class="sd">    A typical sequence is mode=&quot;STATIC&quot; -&gt; mode=&quot;DIAG&quot; -&gt; mode=&quot;GW&quot; -&gt;</span>
<span class="sd">    mode=&quot;BSE&quot;. For all steps other than the first one (static), the</span>
<span class="sd">    recommendation is to use from_prev_calculation on the preceding run in</span>
<span class="sd">    the series.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="n">CONFIG</span> <span class="o">=</span> <span class="n">_load_yaml_config</span><span class="p">(</span><span class="s2">&quot;MVLGWSet&quot;</span><span class="p">)</span>

    <span class="n">SUPPORTED_MODES</span> <span class="o">=</span> <span class="p">(</span><span class="s2">&quot;DIAG&quot;</span><span class="p">,</span> <span class="s2">&quot;GW&quot;</span><span class="p">,</span> <span class="s2">&quot;STATIC&quot;</span><span class="p">,</span> <span class="s2">&quot;BSE&quot;</span><span class="p">)</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span>
            <span class="bp">self</span><span class="p">,</span>
            <span class="n">structure</span><span class="p">,</span>
            <span class="n">prev_incar</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
            <span class="n">nbands</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
            <span class="n">reciprocal_density</span><span class="o">=</span><span class="mi">100</span><span class="p">,</span>
            <span class="n">mode</span><span class="o">=</span><span class="s2">&quot;STATIC&quot;</span><span class="p">,</span>
            <span class="n">copy_wavecar</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
            <span class="n">nbands_factor</span><span class="o">=</span><span class="mi">5</span><span class="p">,</span>
            <span class="n">ncores</span><span class="o">=</span><span class="mi">16</span><span class="p">,</span>
            <span class="o">**</span><span class="n">kwargs</span>
    <span class="p">):</span>
        <span class="sa">r</span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            structure (Structure): Input structure.</span>
<span class="sd">            prev_incar (Incar/string): Incar file from previous run.</span>
<span class="sd">            mode (str): Supported modes are &quot;STATIC&quot; (default), &quot;DIAG&quot;, &quot;GW&quot;,</span>
<span class="sd">                and &quot;BSE&quot;.</span>
<span class="sd">            nbands (int): For subsequent calculations, it is generally</span>
<span class="sd">                recommended to perform NBANDS convergence starting from the</span>
<span class="sd">                NBANDS of the previous run for DIAG, and to use the exact same</span>
<span class="sd">                NBANDS for GW and BSE. This parameter is used by</span>
<span class="sd">                from_previous_calculation to set nband.</span>
<span class="sd">            copy_wavecar: Whether to copy the old WAVECAR, WAVEDER and associated</span>
<span class="sd">                files when starting from a previous calculation.</span>
<span class="sd">            nbands_factor (int): Multiplicative factor for NBANDS when starting</span>
<span class="sd">                from a previous calculation. Only applies if mode==&quot;DIAG&quot;.</span>
<span class="sd">                Need to be tested for convergence.</span>
<span class="sd">            ncores (int): Numbers of cores used for the calculation. VASP will alter</span>
<span class="sd">                NBANDS if it was not dividable by ncores. Only applies if</span>
<span class="sd">                mode==&quot;DIAG&quot;.</span>
<span class="sd">            **kwargs: All kwargs supported by DictSet. Typically,</span>
<span class="sd">                user_incar_settings is a commonly used option.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">structure</span><span class="p">,</span> <span class="n">MVLGWSet</span><span class="o">.</span><span class="n">CONFIG</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">prev_incar</span> <span class="o">=</span> <span class="n">prev_incar</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">nbands</span> <span class="o">=</span> <span class="n">nbands</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">reciprocal_density</span> <span class="o">=</span> <span class="n">reciprocal_density</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">mode</span> <span class="o">=</span> <span class="n">mode</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">mode</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">MVLGWSet</span><span class="o">.</span><span class="n">SUPPORTED_MODES</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;</span><span class="si">%s</span><span class="s2"> not one of the support modes : </span><span class="si">%s</span><span class="s2">&quot;</span>
                <span class="o">%</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">mode</span><span class="p">,</span> <span class="n">MVLGWSet</span><span class="o">.</span><span class="n">SUPPORTED_MODES</span><span class="p">)</span>
            <span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">kwargs</span> <span class="o">=</span> <span class="n">kwargs</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">copy_wavecar</span> <span class="o">=</span> <span class="n">copy_wavecar</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">nbands_factor</span> <span class="o">=</span> <span class="n">nbands_factor</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">ncores</span> <span class="o">=</span> <span class="n">ncores</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">kpoints</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Generate gamma center k-points mesh grid for GW calc,</span>
<span class="sd">        which is requested by GW calculation.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="n">Kpoints</span><span class="o">.</span><span class="n">automatic_density_by_vol</span><span class="p">(</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">structure</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">reciprocal_density</span><span class="p">,</span> <span class="n">force_gamma</span><span class="o">=</span><span class="kc">True</span>
        <span class="p">)</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">incar</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :return: Incar</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">parent_incar</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">incar</span>
        <span class="n">incar</span> <span class="o">=</span> <span class="p">(</span>
            <span class="n">Incar</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">prev_incar</span><span class="p">)</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">prev_incar</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span>
            <span class="k">else</span> <span class="n">Incar</span><span class="p">(</span><span class="n">parent_incar</span><span class="p">)</span>
        <span class="p">)</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">mode</span> <span class="o">==</span> <span class="s2">&quot;DIAG&quot;</span><span class="p">:</span>
            <span class="c1"># Default parameters for diagonalization calculation.</span>
            <span class="n">incar</span><span class="o">.</span><span class="n">update</span><span class="p">({</span><span class="s2">&quot;ALGO&quot;</span><span class="p">:</span> <span class="s2">&quot;Exact&quot;</span><span class="p">,</span> <span class="s2">&quot;NELM&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">&quot;LOPTICS&quot;</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">&quot;LPEAD&quot;</span><span class="p">:</span> <span class="kc">True</span><span class="p">})</span>
        <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">mode</span> <span class="o">==</span> <span class="s2">&quot;GW&quot;</span><span class="p">:</span>
            <span class="c1"># Default parameters for GW calculation.</span>
            <span class="n">incar</span><span class="o">.</span><span class="n">update</span><span class="p">({</span><span class="s2">&quot;ALGO&quot;</span><span class="p">:</span> <span class="s2">&quot;GW0&quot;</span><span class="p">,</span> <span class="s2">&quot;NELM&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">&quot;NOMEGA&quot;</span><span class="p">:</span> <span class="mi">80</span><span class="p">,</span> <span class="s2">&quot;ENCUTGW&quot;</span><span class="p">:</span> <span class="mi">250</span><span class="p">})</span>
            <span class="n">incar</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">&quot;EDIFF&quot;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
            <span class="n">incar</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">&quot;LOPTICS&quot;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
            <span class="n">incar</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">&quot;LPEAD&quot;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
        <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">mode</span> <span class="o">==</span> <span class="s2">&quot;BSE&quot;</span><span class="p">:</span>
            <span class="c1"># Default parameters for BSE calculation.</span>
            <span class="n">incar</span><span class="o">.</span><span class="n">update</span><span class="p">({</span><span class="s2">&quot;ALGO&quot;</span><span class="p">:</span> <span class="s2">&quot;BSE&quot;</span><span class="p">,</span> <span class="s2">&quot;ANTIRES&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="s2">&quot;NBANDSO&quot;</span><span class="p">:</span> <span class="mi">20</span><span class="p">,</span> <span class="s2">&quot;NBANDSV&quot;</span><span class="p">:</span> <span class="mi">20</span><span class="p">})</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">nbands</span><span class="p">:</span>
            <span class="n">incar</span><span class="p">[</span><span class="s2">&quot;NBANDS&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">nbands</span>

        <span class="c1"># Respect user set INCAR.</span>
        <span class="n">incar</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;user_incar_settings&quot;</span><span class="p">,</span> <span class="p">{}))</span>

        <span class="k">return</span> <span class="n">incar</span>

<div class="viewcode-block" id="MVLGWSet.override_from_prev_calc"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.MVLGWSet.override_from_prev_calc">[docs]</a>    <span class="k">def</span> <span class="nf">override_from_prev_calc</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prev_calc_dir</span><span class="o">=</span><span class="s2">&quot;.&quot;</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Update the input set to include settings from a previous calculation.</span>

<span class="sd">        Args:</span>
<span class="sd">            prev_calc_dir (str): The path to the previous calculation directory.</span>

<span class="sd">        Returns:</span>
<span class="sd">            The input set with the settings (structure, k-points, incar, etc)</span>
<span class="sd">            updated using the previous VASP run.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">vasprun</span><span class="p">,</span> <span class="n">outcar</span> <span class="o">=</span> <span class="n">get_vasprun_outcar</span><span class="p">(</span><span class="n">prev_calc_dir</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">prev_incar</span> <span class="o">=</span> <span class="n">vasprun</span><span class="o">.</span><span class="n">incar</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_structure</span> <span class="o">=</span> <span class="n">vasprun</span><span class="o">.</span><span class="n">final_structure</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">standardize</span><span class="p">:</span>
            <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span>
                <span class="s2">&quot;Use of standardize=True with from_prev_run is not &quot;</span>
                <span class="s2">&quot;recommended as there is no guarantee the copied &quot;</span>
                <span class="s2">&quot;files will be appropriate for the standardized &quot;</span>
                <span class="s2">&quot;structure.&quot;</span>
            <span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">nbands</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">vasprun</span><span class="o">.</span><span class="n">parameters</span><span class="p">[</span><span class="s2">&quot;NBANDS&quot;</span><span class="p">])</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">mode</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;DIAG&quot;</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">nbands</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span>
                <span class="n">np</span><span class="o">.</span><span class="n">ceil</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">nbands</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">nbands_factor</span> <span class="o">/</span> <span class="bp">self</span><span class="o">.</span><span class="n">ncores</span><span class="p">)</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">ncores</span>
            <span class="p">)</span>

        <span class="c1"># copy WAVECAR, WAVEDER (derivatives)</span>
        <span class="n">files_to_transfer</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy_wavecar</span><span class="p">:</span>
            <span class="k">for</span> <span class="n">fname</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">&quot;WAVECAR&quot;</span><span class="p">,</span> <span class="s2">&quot;WAVEDER&quot;</span><span class="p">,</span> <span class="s2">&quot;WFULL&quot;</span><span class="p">):</span>
                <span class="n">w</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">glob</span><span class="o">.</span><span class="n">glob</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">Path</span><span class="p">(</span><span class="n">prev_calc_dir</span><span class="p">)</span> <span class="o">/</span> <span class="p">(</span><span class="n">fname</span> <span class="o">+</span> <span class="s2">&quot;*&quot;</span><span class="p">))))</span>
                <span class="k">if</span> <span class="n">w</span><span class="p">:</span>
                    <span class="k">if</span> <span class="n">fname</span> <span class="o">==</span> <span class="s2">&quot;WFULL&quot;</span><span class="p">:</span>
                        <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">w</span><span class="p">:</span>
                            <span class="n">fname</span> <span class="o">=</span> <span class="n">Path</span><span class="p">(</span><span class="n">f</span><span class="p">)</span><span class="o">.</span><span class="n">name</span>
                            <span class="n">fname</span> <span class="o">=</span> <span class="n">fname</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;.&quot;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
                            <span class="n">files_to_transfer</span><span class="p">[</span><span class="n">fname</span><span class="p">]</span> <span class="o">=</span> <span class="n">f</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="n">files_to_transfer</span><span class="p">[</span><span class="n">fname</span><span class="p">]</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">w</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">files_to_transfer</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">files_to_transfer</span><span class="p">)</span>

        <span class="k">return</span> <span class="bp">self</span></div>

<div class="viewcode-block" id="MVLGWSet.from_prev_calc"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.MVLGWSet.from_prev_calc">[docs]</a>    <span class="nd">@classmethod</span>
    <span class="k">def</span> <span class="nf">from_prev_calc</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">prev_calc_dir</span><span class="p">,</span> <span class="n">mode</span><span class="o">=</span><span class="s2">&quot;DIAG&quot;</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Generate a set of Vasp input files for GW or BSE calculations from a</span>
<span class="sd">        directory of previous Exact Diag Vasp run.</span>

<span class="sd">        Args:</span>
<span class="sd">            prev_calc_dir (str): The directory contains the outputs(</span>
<span class="sd">                vasprun.xml of previous vasp run.</span>
<span class="sd">            mode (str): Supported modes are &quot;STATIC&quot;, &quot;DIAG&quot; (default), &quot;GW&quot;,</span>
<span class="sd">                and &quot;BSE&quot;.</span>
<span class="sd">            **kwargs: All kwargs supported by MVLGWSet, other than structure,</span>
<span class="sd">                prev_incar and mode, which are determined from the</span>
<span class="sd">                prev_calc_dir.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">input_set</span> <span class="o">=</span> <span class="bp">cls</span><span class="p">(</span><span class="n">_dummy_structure</span><span class="p">,</span> <span class="n">mode</span><span class="o">=</span><span class="n">mode</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">input_set</span><span class="o">.</span><span class="n">override_from_prev_calc</span><span class="p">(</span><span class="n">prev_calc_dir</span><span class="o">=</span><span class="n">prev_calc_dir</span><span class="p">)</span></div></div>


<div class="viewcode-block" id="MVLSlabSet"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.MVLSlabSet">[docs]</a><span class="k">class</span> <span class="nc">MVLSlabSet</span><span class="p">(</span><span class="n">MPRelaxSet</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Class for writing a set of slab vasp runs,</span>
<span class="sd">    including both slabs (along the c direction) and orient unit cells (bulk),</span>
<span class="sd">    to ensure the same KPOINTS, POTCAR and INCAR criterion.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span>
            <span class="bp">self</span><span class="p">,</span>
            <span class="n">structure</span><span class="p">,</span>
            <span class="n">k_product</span><span class="o">=</span><span class="mi">50</span><span class="p">,</span>
            <span class="n">bulk</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
            <span class="n">auto_dipole</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
            <span class="n">set_mix</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
            <span class="n">sort_structure</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
            <span class="o">**</span><span class="n">kwargs</span>
    <span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :param structure: Structure</span>
<span class="sd">        :param k_product: default to 50, kpoint number * length for a &amp; b</span>
<span class="sd">            directions, also for c direction in bulk calculations</span>
<span class="sd">        :param bulk:</span>
<span class="sd">        :param auto_dipole:</span>
<span class="sd">        :param set_mix:</span>
<span class="sd">        :param sort_structure:</span>
<span class="sd">        :param kwargs: Other kwargs supported by :class:`DictSet`.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">structure</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">sort_structure</span><span class="p">:</span>
            <span class="n">structure</span> <span class="o">=</span> <span class="n">structure</span><span class="o">.</span><span class="n">get_sorted_structure</span><span class="p">()</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">k_product</span> <span class="o">=</span> <span class="n">k_product</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">bulk</span> <span class="o">=</span> <span class="n">bulk</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">auto_dipole</span> <span class="o">=</span> <span class="n">auto_dipole</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">kwargs</span> <span class="o">=</span> <span class="n">kwargs</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">set_mix</span> <span class="o">=</span> <span class="n">set_mix</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">kpt_calc</span> <span class="o">=</span> <span class="kc">None</span>

        <span class="n">slab_incar</span> <span class="o">=</span> <span class="p">{</span>
            <span class="s2">&quot;EDIFF&quot;</span><span class="p">:</span> <span class="mf">1e-4</span><span class="p">,</span>
            <span class="s2">&quot;EDIFFG&quot;</span><span class="p">:</span> <span class="o">-</span><span class="mf">0.02</span><span class="p">,</span>
            <span class="s2">&quot;ENCUT&quot;</span><span class="p">:</span> <span class="mi">400</span><span class="p">,</span>
            <span class="s2">&quot;ISMEAR&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
            <span class="s2">&quot;SIGMA&quot;</span><span class="p">:</span> <span class="mf">0.05</span><span class="p">,</span>
            <span class="s2">&quot;ISIF&quot;</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
        <span class="p">}</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">bulk</span><span class="p">:</span>
            <span class="n">slab_incar</span><span class="p">[</span><span class="s2">&quot;ISIF&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">2</span>
            <span class="n">slab_incar</span><span class="p">[</span><span class="s2">&quot;LVTOT&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">set_mix</span><span class="p">:</span>
                <span class="n">slab_incar</span><span class="p">[</span><span class="s2">&quot;AMIN&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="mf">0.01</span>
                <span class="n">slab_incar</span><span class="p">[</span><span class="s2">&quot;AMIX&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="mf">0.2</span>
                <span class="n">slab_incar</span><span class="p">[</span><span class="s2">&quot;BMIX&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="mf">0.001</span>
            <span class="n">slab_incar</span><span class="p">[</span><span class="s2">&quot;NELMIN&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">8</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">auto_dipole</span><span class="p">:</span>
                <span class="n">weights</span> <span class="o">=</span> <span class="p">[</span><span class="n">s</span><span class="o">.</span><span class="n">species</span><span class="o">.</span><span class="n">weight</span> <span class="k">for</span> <span class="n">s</span> <span class="ow">in</span> <span class="n">structure</span><span class="p">]</span>
                <span class="n">center_of_mass</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">average</span><span class="p">(</span>
                    <span class="n">structure</span><span class="o">.</span><span class="n">frac_coords</span><span class="p">,</span> <span class="n">weights</span><span class="o">=</span><span class="n">weights</span><span class="p">,</span> <span class="n">axis</span><span class="o">=</span><span class="mi">0</span>
                <span class="p">)</span>

                <span class="n">slab_incar</span><span class="p">[</span><span class="s2">&quot;IDIPOL&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">3</span>
                <span class="n">slab_incar</span><span class="p">[</span><span class="s2">&quot;LDIPOL&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>
                <span class="n">slab_incar</span><span class="p">[</span><span class="s2">&quot;DIPOL&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">center_of_mass</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">_config_dict</span><span class="p">[</span><span class="s2">&quot;INCAR&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">slab_incar</span><span class="p">)</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">kpoints</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        k_product, default to 50, is kpoint number * length for a &amp; b</span>
<span class="sd">            directions, also for c direction in bulk calculations</span>
<span class="sd">        Automatic mesh &amp; Gamma is the default setting.</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="c1"># To get input sets, the input structure has to has the same number</span>
        <span class="c1"># of required parameters as a Structure object (ie. 4). Slab</span>
        <span class="c1"># attributes aren&#39;t going to affect the VASP inputs anyways so</span>
        <span class="c1"># converting the slab into a structure should not matter</span>

        <span class="n">kpt</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">kpoints</span>
        <span class="n">kpt</span><span class="o">.</span><span class="n">comment</span> <span class="o">=</span> <span class="s2">&quot;Automatic mesh&quot;</span>
        <span class="n">kpt</span><span class="o">.</span><span class="n">style</span> <span class="o">=</span> <span class="s2">&quot;Gamma&quot;</span>

        <span class="c1"># use k_product to calculate kpoints, k_product = kpts[0][0] * a</span>
        <span class="n">lattice_abc</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">structure</span><span class="o">.</span><span class="n">lattice</span><span class="o">.</span><span class="n">abc</span>
        <span class="n">kpt_calc</span> <span class="o">=</span> <span class="p">[</span>
            <span class="nb">int</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">k_product</span> <span class="o">/</span> <span class="n">lattice_abc</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="mf">0.5</span><span class="p">),</span>
            <span class="nb">int</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">k_product</span> <span class="o">/</span> <span class="n">lattice_abc</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="mf">0.5</span><span class="p">),</span>
            <span class="mi">1</span><span class="p">,</span>
        <span class="p">]</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">kpt_calc</span> <span class="o">=</span> <span class="n">kpt_calc</span>
        <span class="c1"># calculate kpts (c direction) for bulk. (for slab, set to 1)</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">bulk</span><span class="p">:</span>
            <span class="n">kpt_calc</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">k_product</span> <span class="o">/</span> <span class="n">lattice_abc</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">+</span> <span class="mf">0.5</span><span class="p">)</span>

        <span class="n">kpt</span><span class="o">.</span><span class="n">kpts</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="n">kpt_calc</span>

        <span class="k">return</span> <span class="n">kpt</span>

<div class="viewcode-block" id="MVLSlabSet.as_dict"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.MVLSlabSet.as_dict">[docs]</a>    <span class="k">def</span> <span class="nf">as_dict</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">verbosity</span><span class="o">=</span><span class="mi">2</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :param verbosity: Verbosity of dict. E.g., whether to include Structure.</span>
<span class="sd">        :return: MSONAble dict</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">d</span> <span class="o">=</span> <span class="n">MSONable</span><span class="o">.</span><span class="n">as_dict</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">verbosity</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
            <span class="n">d</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">&quot;structure&quot;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">d</span></div></div>


<div class="viewcode-block" id="MVLGBSet"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.MVLGBSet">[docs]</a><span class="k">class</span> <span class="nc">MVLGBSet</span><span class="p">(</span><span class="n">MPRelaxSet</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Class for writing a vasp input files for grain boundary calculations, slab</span>
<span class="sd">    or bulk.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span>
            <span class="bp">self</span><span class="p">,</span> <span class="n">structure</span><span class="p">,</span> <span class="n">k_product</span><span class="o">=</span><span class="mi">40</span><span class="p">,</span> <span class="n">slab_mode</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">is_metal</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span>
    <span class="p">):</span>
        <span class="sa">r</span><span class="sd">&quot;&quot;&quot;</span>

<span class="sd">        Args:</span>
<span class="sd">            structure(Structure): provide the structure</span>
<span class="sd">            k_product: Kpoint number * length for a &amp; b directions, also for c</span>
<span class="sd">                direction in bulk calculations. Default to 40.</span>
<span class="sd">            slab_mode (bool): Defaults to False. Use default (False) for a</span>
<span class="sd">                bulk supercell. Use True if you are performing calculations on a</span>
<span class="sd">                slab-like (i.e., surface) of the GB, for example, when you are</span>
<span class="sd">                calculating the work of separation.</span>
<span class="sd">            is_metal (bool): Defaults to True. This determines whether an ISMEAR of</span>
<span class="sd">                1 is used (for metals) or not (for insulators and semiconductors)</span>
<span class="sd">                by default. Note that it does *not* override user_incar_settings,</span>
<span class="sd">                which can be set by the user to be anything desired.</span>
<span class="sd">            **kwargs:</span>
<span class="sd">                Other kwargs supported by :class:`MPRelaxSet`.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">structure</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">k_product</span> <span class="o">=</span> <span class="n">k_product</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">slab_mode</span> <span class="o">=</span> <span class="n">slab_mode</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">is_metal</span> <span class="o">=</span> <span class="n">is_metal</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">kpoints</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        k_product, default to 40, is kpoint number * length for a &amp; b</span>
<span class="sd">        directions, also for c direction in bulk calculations</span>
<span class="sd">        Automatic mesh &amp; Gamma is the default setting.</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="c1"># To get input sets, the input structure has to has the same number</span>
        <span class="c1"># of required parameters as a Structure object.</span>

        <span class="n">kpt</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">kpoints</span>
        <span class="n">kpt</span><span class="o">.</span><span class="n">comment</span> <span class="o">=</span> <span class="s2">&quot;Generated by pymatgen&#39;s MVLGBSet&quot;</span>
        <span class="n">kpt</span><span class="o">.</span><span class="n">style</span> <span class="o">=</span> <span class="s2">&quot;Gamma&quot;</span>

        <span class="c1"># use k_product to calculate kpoints, k_product = kpts[0][0] * a</span>
        <span class="n">lengths</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">structure</span><span class="o">.</span><span class="n">lattice</span><span class="o">.</span><span class="n">abc</span>
        <span class="n">kpt_calc</span> <span class="o">=</span> <span class="p">[</span>
            <span class="nb">int</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">k_product</span> <span class="o">/</span> <span class="n">lengths</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="mf">0.5</span><span class="p">),</span>
            <span class="nb">int</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">k_product</span> <span class="o">/</span> <span class="n">lengths</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="mf">0.5</span><span class="p">),</span>
            <span class="nb">int</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">k_product</span> <span class="o">/</span> <span class="n">lengths</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">+</span> <span class="mf">0.5</span><span class="p">),</span>
        <span class="p">]</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">slab_mode</span><span class="p">:</span>
            <span class="n">kpt_calc</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">=</span> <span class="mi">1</span>

        <span class="n">kpt</span><span class="o">.</span><span class="n">kpts</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="n">kpt_calc</span>

        <span class="k">return</span> <span class="n">kpt</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">incar</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :return: Incar</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">incar</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">incar</span>

        <span class="c1"># The default incar setting is used for metallic system, for</span>
        <span class="c1"># insulator or semiconductor, ISMEAR need to be changed.</span>
        <span class="n">incar</span><span class="o">.</span><span class="n">update</span><span class="p">(</span>
            <span class="p">{</span>
                <span class="s2">&quot;LCHARG&quot;</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span>
                <span class="s2">&quot;NELM&quot;</span><span class="p">:</span> <span class="mi">60</span><span class="p">,</span>
                <span class="s2">&quot;PREC&quot;</span><span class="p">:</span> <span class="s2">&quot;Normal&quot;</span><span class="p">,</span>
                <span class="s2">&quot;EDIFFG&quot;</span><span class="p">:</span> <span class="o">-</span><span class="mf">0.02</span><span class="p">,</span>
                <span class="s2">&quot;ICHARG&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
                <span class="s2">&quot;NSW&quot;</span><span class="p">:</span> <span class="mi">200</span><span class="p">,</span>
                <span class="s2">&quot;EDIFF&quot;</span><span class="p">:</span> <span class="mf">0.0001</span><span class="p">,</span>
            <span class="p">}</span>
        <span class="p">)</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_metal</span><span class="p">:</span>
            <span class="n">incar</span><span class="p">[</span><span class="s2">&quot;ISMEAR&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">1</span>
            <span class="n">incar</span><span class="p">[</span><span class="s2">&quot;LDAU&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">False</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">slab_mode</span><span class="p">:</span>
            <span class="c1"># for clean grain boundary and bulk relaxation, full optimization</span>
            <span class="c1"># relaxation (ISIF=3) is used. For slab relaxation (ISIF=2) is used.</span>
            <span class="n">incar</span><span class="p">[</span><span class="s2">&quot;ISIF&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">2</span>
            <span class="n">incar</span><span class="p">[</span><span class="s2">&quot;NELMIN&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">8</span>

        <span class="n">incar</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">user_incar_settings</span><span class="p">)</span>

        <span class="k">return</span> <span class="n">incar</span></div>


<div class="viewcode-block" id="MVLRelax52Set"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.MVLRelax52Set">[docs]</a><span class="k">class</span> <span class="nc">MVLRelax52Set</span><span class="p">(</span><span class="n">DictSet</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Implementation of VaspInputSet utilizing the public Materials Project</span>
<span class="sd">    parameters for INCAR &amp; KPOINTS and VASP&#39;s recommended PAW potentials for</span>
<span class="sd">    POTCAR.</span>

<span class="sd">    Keynotes from VASP manual:</span>
<span class="sd">        1. Recommended potentials for calculations using vasp.5.2+</span>
<span class="sd">        2. If dimers with short bonds are present in the compound (O2, CO,</span>
<span class="sd">            N2, F2, P2, S2, Cl2), it is recommended to use the h potentials.</span>
<span class="sd">            Specifically, C_h, O_h, N_h, F_h, P_h, S_h, Cl_h</span>
<span class="sd">        3. Released on Oct 28, 2018 by VASP. Please refer to VASP</span>
<span class="sd">            Manual 1.2, 1.3 &amp; 10.2.1 for more details.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="n">CONFIG</span> <span class="o">=</span> <span class="n">_load_yaml_config</span><span class="p">(</span><span class="s2">&quot;MVLRelax52Set&quot;</span><span class="p">)</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">structure</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            structure (Structure): input structure.</span>
<span class="sd">            potcar_functional (str): choose from &quot;PBE_52&quot; and &quot;PBE_54&quot;.</span>
<span class="sd">            **kwargs: Other kwargs supported by :class:`DictSet`.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;potcar_functional&quot;</span><span class="p">)</span> <span class="ow">or</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;user_potcar_functional&quot;</span><span class="p">):</span>
            <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">structure</span><span class="p">,</span> <span class="n">MVLRelax52Set</span><span class="o">.</span><span class="n">CONFIG</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span>
                <span class="n">structure</span><span class="p">,</span>
                <span class="n">MVLRelax52Set</span><span class="o">.</span><span class="n">CONFIG</span><span class="p">,</span>
                <span class="n">user_potcar_functional</span><span class="o">=</span><span class="s2">&quot;PBE_52&quot;</span><span class="p">,</span>
                <span class="o">**</span><span class="n">kwargs</span>
            <span class="p">)</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">potcar_functional</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;PBE_52&quot;</span><span class="p">,</span> <span class="s2">&quot;PBE_54&quot;</span><span class="p">]:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;Please select from PBE_52 and PBE_54!&quot;</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">kwargs</span> <span class="o">=</span> <span class="n">kwargs</span></div>


<div class="viewcode-block" id="MITNEBSet"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.MITNEBSet">[docs]</a><span class="k">class</span> <span class="nc">MITNEBSet</span><span class="p">(</span><span class="n">MITRelaxSet</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Class for writing NEB inputs. Note that EDIFF is not on a per atom</span>
<span class="sd">    basis for this input set.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">structures</span><span class="p">,</span> <span class="n">unset_encut</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            structures: List of Structure objects.</span>
<span class="sd">            unset_encut (bool): Whether to unset ENCUT.</span>
<span class="sd">            **kwargs: Other kwargs supported by :class:`DictSet`.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">structures</span><span class="p">)</span> <span class="o">&lt;</span> <span class="mi">3</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;You need at least 3 structures for an NEB.&quot;</span><span class="p">)</span>
        <span class="n">kwargs</span><span class="p">[</span><span class="s2">&quot;sort_structure&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">structures</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">structures</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_process_structures</span><span class="p">(</span><span class="n">structures</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">unset_encut</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="k">if</span> <span class="n">unset_encut</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_config_dict</span><span class="p">[</span><span class="s2">&quot;INCAR&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">&quot;ENCUT&quot;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>

        <span class="k">if</span> <span class="s2">&quot;EDIFF&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_config_dict</span><span class="p">[</span><span class="s2">&quot;INCAR&quot;</span><span class="p">]:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_config_dict</span><span class="p">[</span><span class="s2">&quot;INCAR&quot;</span><span class="p">][</span><span class="s2">&quot;EDIFF&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_config_dict</span><span class="p">[</span><span class="s2">&quot;INCAR&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span>
                <span class="s2">&quot;EDIFF_PER_ATOM&quot;</span>
            <span class="p">)</span>

        <span class="c1"># NEB specific defaults</span>
        <span class="n">defaults</span> <span class="o">=</span> <span class="p">{</span>
            <span class="s2">&quot;IMAGES&quot;</span><span class="p">:</span> <span class="nb">len</span><span class="p">(</span><span class="n">structures</span><span class="p">)</span> <span class="o">-</span> <span class="mi">2</span><span class="p">,</span>
            <span class="s2">&quot;IBRION&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
            <span class="s2">&quot;ISYM&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
            <span class="s2">&quot;LCHARG&quot;</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span>
            <span class="s2">&quot;LDAU&quot;</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span>
        <span class="p">}</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_config_dict</span><span class="p">[</span><span class="s2">&quot;INCAR&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">defaults</span><span class="p">)</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">poscar</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :return: Poscar for structure of first end point.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="n">Poscar</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">structures</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">poscars</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :return: List of Poscars.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="p">[</span><span class="n">Poscar</span><span class="p">(</span><span class="n">s</span><span class="p">)</span> <span class="k">for</span> <span class="n">s</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">structures</span><span class="p">]</span>

    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">_process_structures</span><span class="p">(</span><span class="n">structures</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Remove any atom jumps across the cell</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">input_structures</span> <span class="o">=</span> <span class="n">structures</span>
        <span class="n">structures</span> <span class="o">=</span> <span class="p">[</span><span class="n">input_structures</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span>
        <span class="k">for</span> <span class="n">s</span> <span class="ow">in</span> <span class="n">input_structures</span><span class="p">[</span><span class="mi">1</span><span class="p">:]:</span>
            <span class="n">prev</span> <span class="o">=</span> <span class="n">structures</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
            <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">s</span><span class="p">)):</span>
                <span class="n">t</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">round</span><span class="p">(</span><span class="n">prev</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">frac_coords</span> <span class="o">-</span> <span class="n">s</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">frac_coords</span><span class="p">)</span>
                <span class="k">if</span> <span class="n">np</span><span class="o">.</span><span class="n">any</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">abs</span><span class="p">(</span><span class="n">t</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mf">0.5</span><span class="p">):</span>
                    <span class="n">s</span><span class="o">.</span><span class="n">translate_sites</span><span class="p">([</span><span class="n">i</span><span class="p">],</span> <span class="n">t</span><span class="p">,</span> <span class="n">to_unit_cell</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
            <span class="n">structures</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">s</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">structures</span>

<div class="viewcode-block" id="MITNEBSet.write_input"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.MITNEBSet.write_input">[docs]</a>    <span class="k">def</span> <span class="nf">write_input</span><span class="p">(</span>
            <span class="bp">self</span><span class="p">,</span>
            <span class="n">output_dir</span><span class="p">,</span>
            <span class="n">make_dir_if_not_present</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
            <span class="n">write_cif</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
            <span class="n">write_path_cif</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
            <span class="n">write_endpoint_inputs</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
    <span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        NEB inputs has a special directory structure where inputs are in 00,</span>
<span class="sd">        01, 02, ....</span>

<span class="sd">        Args:</span>
<span class="sd">            output_dir (str): Directory to output the VASP input files</span>
<span class="sd">            make_dir_if_not_present (bool): Set to True if you want the</span>
<span class="sd">                directory (and the whole path) to be created if it is not</span>
<span class="sd">                present.</span>
<span class="sd">            write_cif (bool): If true, writes a cif along with each POSCAR.</span>
<span class="sd">            write_path_cif (bool): If true, writes a cif for each image.</span>
<span class="sd">            write_endpoint_inputs (bool): If true, writes input files for</span>
<span class="sd">                running endpoint calculations.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">output_dir</span> <span class="o">=</span> <span class="n">Path</span><span class="p">(</span><span class="n">output_dir</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">make_dir_if_not_present</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">output_dir</span><span class="o">.</span><span class="n">exists</span><span class="p">():</span>
            <span class="n">output_dir</span><span class="o">.</span><span class="n">mkdir</span><span class="p">(</span><span class="n">parents</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">incar</span><span class="o">.</span><span class="n">write_file</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">output_dir</span> <span class="o">/</span> <span class="s2">&quot;INCAR&quot;</span><span class="p">))</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">kpoints</span><span class="o">.</span><span class="n">write_file</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">output_dir</span> <span class="o">/</span> <span class="s2">&quot;KPOINTS&quot;</span><span class="p">))</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">potcar</span><span class="o">.</span><span class="n">write_file</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">output_dir</span> <span class="o">/</span> <span class="s2">&quot;POTCAR&quot;</span><span class="p">))</span>

        <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">p</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">poscars</span><span class="p">):</span>
            <span class="n">d</span> <span class="o">=</span> <span class="n">output_dir</span> <span class="o">/</span> <span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="p">)</span><span class="o">.</span><span class="n">zfill</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="n">d</span><span class="o">.</span><span class="n">exists</span><span class="p">():</span>
                <span class="n">d</span><span class="o">.</span><span class="n">mkdir</span><span class="p">(</span><span class="n">parents</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
            <span class="n">p</span><span class="o">.</span><span class="n">write_file</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">d</span> <span class="o">/</span> <span class="s2">&quot;POSCAR&quot;</span><span class="p">))</span>
            <span class="k">if</span> <span class="n">write_cif</span><span class="p">:</span>
                <span class="n">p</span><span class="o">.</span><span class="n">structure</span><span class="o">.</span><span class="n">to</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">d</span> <span class="o">/</span> <span class="s2">&quot;</span><span class="si">{}</span><span class="s2">.cif&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">i</span><span class="p">)))</span>
        <span class="k">if</span> <span class="n">write_endpoint_inputs</span><span class="p">:</span>
            <span class="n">end_point_param</span> <span class="o">=</span> <span class="n">MITRelaxSet</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">structures</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">user_incar_settings</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">user_incar_settings</span>
            <span class="p">)</span>

            <span class="k">for</span> <span class="n">image</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;00&quot;</span><span class="p">,</span> <span class="nb">str</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">structures</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">zfill</span><span class="p">(</span><span class="mi">2</span><span class="p">)]:</span>
                <span class="n">end_point_param</span><span class="o">.</span><span class="n">incar</span><span class="o">.</span><span class="n">write_file</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">output_dir</span> <span class="o">/</span> <span class="n">image</span> <span class="o">/</span> <span class="s2">&quot;INCAR&quot;</span><span class="p">))</span>
                <span class="n">end_point_param</span><span class="o">.</span><span class="n">kpoints</span><span class="o">.</span><span class="n">write_file</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">output_dir</span> <span class="o">/</span> <span class="n">image</span> <span class="o">/</span> <span class="s2">&quot;KPOINTS&quot;</span><span class="p">))</span>
                <span class="n">end_point_param</span><span class="o">.</span><span class="n">potcar</span><span class="o">.</span><span class="n">write_file</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">output_dir</span> <span class="o">/</span> <span class="n">image</span> <span class="o">/</span> <span class="s2">&quot;POTCAR&quot;</span><span class="p">))</span>
        <span class="k">if</span> <span class="n">write_path_cif</span><span class="p">:</span>
            <span class="n">sites</span> <span class="o">=</span> <span class="nb">set</span><span class="p">()</span>
            <span class="n">lat</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">structures</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">lattice</span>
            <span class="k">for</span> <span class="n">site</span> <span class="ow">in</span> <span class="n">chain</span><span class="p">(</span><span class="o">*</span><span class="p">(</span><span class="n">s</span><span class="o">.</span><span class="n">sites</span> <span class="k">for</span> <span class="n">s</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">structures</span><span class="p">)):</span>
                <span class="n">sites</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">PeriodicSite</span><span class="p">(</span><span class="n">site</span><span class="o">.</span><span class="n">species</span><span class="p">,</span> <span class="n">site</span><span class="o">.</span><span class="n">frac_coords</span><span class="p">,</span> <span class="n">lat</span><span class="p">))</span>
            <span class="n">nebpath</span> <span class="o">=</span> <span class="n">Structure</span><span class="o">.</span><span class="n">from_sites</span><span class="p">(</span><span class="nb">sorted</span><span class="p">(</span><span class="n">sites</span><span class="p">))</span>
            <span class="n">nebpath</span><span class="o">.</span><span class="n">to</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">output_dir</span> <span class="o">/</span> <span class="s2">&quot;path.cif&quot;</span><span class="p">))</span></div></div>


<div class="viewcode-block" id="MITMDSet"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.MITMDSet">[docs]</a><span class="k">class</span> <span class="nc">MITMDSet</span><span class="p">(</span><span class="n">MITRelaxSet</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Class for writing a vasp md run. This DOES NOT do multiple stage</span>
<span class="sd">    runs.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span>
            <span class="bp">self</span><span class="p">,</span>
            <span class="n">structure</span><span class="p">,</span>
            <span class="n">start_temp</span><span class="p">,</span>
            <span class="n">end_temp</span><span class="p">,</span>
            <span class="n">nsteps</span><span class="p">,</span>
            <span class="n">time_step</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span>
            <span class="n">spin_polarized</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
            <span class="o">**</span><span class="n">kwargs</span>
    <span class="p">):</span>
        <span class="sa">r</span><span class="sd">&quot;&quot;&quot;</span>

<span class="sd">        Args:</span>
<span class="sd">            structure (Structure): Input structure.</span>
<span class="sd">            start_temp (int): Starting temperature.</span>
<span class="sd">            end_temp (int): Final temperature.</span>
<span class="sd">            nsteps (int): Number of time steps for simulations. NSW parameter.</span>
<span class="sd">            time_step (int): The time step for the simulation. The POTIM</span>
<span class="sd">                parameter. Defaults to 2fs.</span>
<span class="sd">            spin_polarized (bool): Whether to do spin polarized calculations.</span>
<span class="sd">                The ISPIN parameter. Defaults to False.</span>
<span class="sd">            **kwargs: Other kwargs supported by :class:`DictSet`.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="c1"># MD default settings</span>
        <span class="n">defaults</span> <span class="o">=</span> <span class="p">{</span>
            <span class="s2">&quot;TEBEG&quot;</span><span class="p">:</span> <span class="n">start_temp</span><span class="p">,</span>
            <span class="s2">&quot;TEEND&quot;</span><span class="p">:</span> <span class="n">end_temp</span><span class="p">,</span>
            <span class="s2">&quot;NSW&quot;</span><span class="p">:</span> <span class="n">nsteps</span><span class="p">,</span>
            <span class="s2">&quot;EDIFF_PER_ATOM&quot;</span><span class="p">:</span> <span class="mf">0.000001</span><span class="p">,</span>
            <span class="s2">&quot;LSCALU&quot;</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span>
            <span class="s2">&quot;LCHARG&quot;</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span>
            <span class="s2">&quot;LPLANE&quot;</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span>
            <span class="s2">&quot;LWAVE&quot;</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span>
            <span class="s2">&quot;ISMEAR&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
            <span class="s2">&quot;NELMIN&quot;</span><span class="p">:</span> <span class="mi">4</span><span class="p">,</span>
            <span class="s2">&quot;LREAL&quot;</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span>
            <span class="s2">&quot;BMIX&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
            <span class="s2">&quot;MAXMIX&quot;</span><span class="p">:</span> <span class="mi">20</span><span class="p">,</span>
            <span class="s2">&quot;NELM&quot;</span><span class="p">:</span> <span class="mi">500</span><span class="p">,</span>
            <span class="s2">&quot;NSIM&quot;</span><span class="p">:</span> <span class="mi">4</span><span class="p">,</span>
            <span class="s2">&quot;ISYM&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
            <span class="s2">&quot;ISIF&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
            <span class="s2">&quot;IBRION&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
            <span class="s2">&quot;NBLOCK&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
            <span class="s2">&quot;KBLOCK&quot;</span><span class="p">:</span> <span class="mi">100</span><span class="p">,</span>
            <span class="s2">&quot;SMASS&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
            <span class="s2">&quot;POTIM&quot;</span><span class="p">:</span> <span class="n">time_step</span><span class="p">,</span>
            <span class="s2">&quot;PREC&quot;</span><span class="p">:</span> <span class="s2">&quot;Low&quot;</span><span class="p">,</span>
            <span class="s2">&quot;ISPIN&quot;</span><span class="p">:</span> <span class="mi">2</span> <span class="k">if</span> <span class="n">spin_polarized</span> <span class="k">else</span> <span class="mi">1</span><span class="p">,</span>
            <span class="s2">&quot;LDAU&quot;</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span>
        <span class="p">}</span>

        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">structure</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">start_temp</span> <span class="o">=</span> <span class="n">start_temp</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">end_temp</span> <span class="o">=</span> <span class="n">end_temp</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">nsteps</span> <span class="o">=</span> <span class="n">nsteps</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">time_step</span> <span class="o">=</span> <span class="n">time_step</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">spin_polarized</span> <span class="o">=</span> <span class="n">spin_polarized</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">kwargs</span> <span class="o">=</span> <span class="n">kwargs</span>

        <span class="c1"># use VASP default ENCUT</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_config_dict</span><span class="p">[</span><span class="s2">&quot;INCAR&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">&quot;ENCUT&quot;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">defaults</span><span class="p">[</span><span class="s2">&quot;ISPIN&quot;</span><span class="p">]</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_config_dict</span><span class="p">[</span><span class="s2">&quot;INCAR&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">&quot;MAGMOM&quot;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_config_dict</span><span class="p">[</span><span class="s2">&quot;INCAR&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">defaults</span><span class="p">)</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">kpoints</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :return: Kpoints</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="n">Kpoints</span><span class="o">.</span><span class="n">gamma_automatic</span><span class="p">()</span></div>


<div class="viewcode-block" id="MPMDSet"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.MPMDSet">[docs]</a><span class="k">class</span> <span class="nc">MPMDSet</span><span class="p">(</span><span class="n">MPRelaxSet</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    This a modified version of the old MITMDSet pre 2018/03/12.</span>

<span class="sd">    This set serves as the basis for the amorphous skyline paper.</span>

<span class="sd">    (1) Aykol, M.; Dwaraknath, S. S.; Sun, W.; Persson, K. A. Thermodynamic</span>
<span class="sd">        Limit for Synthesis of Metastable Inorganic Materials. Sci. Adv. 2018,</span>
<span class="sd">        4 (4).</span>

<span class="sd">    Class for writing a vasp md run. This DOES NOT do multiple stage runs.</span>
<span class="sd">    Precision remains normal, to increase accuracy of stress tensor.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span>
            <span class="bp">self</span><span class="p">,</span> <span class="n">structure</span><span class="p">,</span> <span class="n">start_temp</span><span class="p">,</span> <span class="n">end_temp</span><span class="p">,</span> <span class="n">nsteps</span><span class="p">,</span> <span class="n">spin_polarized</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span>
    <span class="p">):</span>
        <span class="sa">r</span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            structure (Structure): Input structure.</span>
<span class="sd">            start_temp (int): Starting temperature.</span>
<span class="sd">            end_temp (int): Final temperature.</span>
<span class="sd">            nsteps (int): Number of time steps for simulations. NSW parameter.</span>
<span class="sd">            time_step (int): The time step for the simulation. The POTIM</span>
<span class="sd">                parameter. Defaults to 2fs.</span>
<span class="sd">            spin_polarized (bool): Whether to do spin polarized calculations.</span>
<span class="sd">                The ISPIN parameter. Defaults to False.</span>
<span class="sd">            **kwargs: Other kwargs supported by :class:`DictSet`.</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="c1"># MD default settings</span>
        <span class="n">defaults</span> <span class="o">=</span> <span class="p">{</span>
            <span class="s2">&quot;TEBEG&quot;</span><span class="p">:</span> <span class="n">start_temp</span><span class="p">,</span>
            <span class="s2">&quot;TEEND&quot;</span><span class="p">:</span> <span class="n">end_temp</span><span class="p">,</span>
            <span class="s2">&quot;NSW&quot;</span><span class="p">:</span> <span class="n">nsteps</span><span class="p">,</span>
            <span class="s2">&quot;EDIFF_PER_ATOM&quot;</span><span class="p">:</span> <span class="mf">0.00001</span><span class="p">,</span>
            <span class="s2">&quot;LSCALU&quot;</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span>
            <span class="s2">&quot;LCHARG&quot;</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span>
            <span class="s2">&quot;LPLANE&quot;</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span>
            <span class="s2">&quot;LWAVE&quot;</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span>
            <span class="s2">&quot;ISMEAR&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
            <span class="s2">&quot;NELMIN&quot;</span><span class="p">:</span> <span class="mi">4</span><span class="p">,</span>
            <span class="s2">&quot;LREAL&quot;</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span>
            <span class="s2">&quot;BMIX&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
            <span class="s2">&quot;MAXMIX&quot;</span><span class="p">:</span> <span class="mi">20</span><span class="p">,</span>
            <span class="s2">&quot;NELM&quot;</span><span class="p">:</span> <span class="mi">500</span><span class="p">,</span>
            <span class="s2">&quot;NSIM&quot;</span><span class="p">:</span> <span class="mi">4</span><span class="p">,</span>
            <span class="s2">&quot;ISYM&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
            <span class="s2">&quot;ISIF&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
            <span class="s2">&quot;IBRION&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
            <span class="s2">&quot;NBLOCK&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
            <span class="s2">&quot;KBLOCK&quot;</span><span class="p">:</span> <span class="mi">100</span><span class="p">,</span>
            <span class="s2">&quot;SMASS&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
            <span class="s2">&quot;POTIM&quot;</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span>
            <span class="s2">&quot;PREC&quot;</span><span class="p">:</span> <span class="s2">&quot;Normal&quot;</span><span class="p">,</span>
            <span class="s2">&quot;ISPIN&quot;</span><span class="p">:</span> <span class="mi">2</span> <span class="k">if</span> <span class="n">spin_polarized</span> <span class="k">else</span> <span class="mi">1</span><span class="p">,</span>
            <span class="s2">&quot;LDAU&quot;</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span>
            <span class="s2">&quot;ADDGRID&quot;</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span>
        <span class="p">}</span>

        <span class="k">if</span> <span class="n">Element</span><span class="p">(</span><span class="s2">&quot;H&quot;</span><span class="p">)</span> <span class="ow">in</span> <span class="n">structure</span><span class="o">.</span><span class="n">species</span><span class="p">:</span>
            <span class="n">defaults</span><span class="p">[</span><span class="s2">&quot;POTIM&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="mf">0.5</span>
            <span class="n">defaults</span><span class="p">[</span><span class="s2">&quot;NSW&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">defaults</span><span class="p">[</span><span class="s2">&quot;NSW&quot;</span><span class="p">]</span> <span class="o">*</span> <span class="mi">4</span>

        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">structure</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">start_temp</span> <span class="o">=</span> <span class="n">start_temp</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">end_temp</span> <span class="o">=</span> <span class="n">end_temp</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">nsteps</span> <span class="o">=</span> <span class="n">nsteps</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">spin_polarized</span> <span class="o">=</span> <span class="n">spin_polarized</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">kwargs</span> <span class="o">=</span> <span class="n">kwargs</span>

        <span class="c1"># use VASP default ENCUT</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_config_dict</span><span class="p">[</span><span class="s2">&quot;INCAR&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">&quot;ENCUT&quot;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">defaults</span><span class="p">[</span><span class="s2">&quot;ISPIN&quot;</span><span class="p">]</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_config_dict</span><span class="p">[</span><span class="s2">&quot;INCAR&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">&quot;MAGMOM&quot;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_config_dict</span><span class="p">[</span><span class="s2">&quot;INCAR&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">defaults</span><span class="p">)</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">kpoints</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :return: Kpoints</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="n">Kpoints</span><span class="o">.</span><span class="n">gamma_automatic</span><span class="p">()</span></div>


<div class="viewcode-block" id="MVLNPTMDSet"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.MVLNPTMDSet">[docs]</a><span class="k">class</span> <span class="nc">MVLNPTMDSet</span><span class="p">(</span><span class="n">MITMDSet</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Class for writing a vasp md run in NPT ensemble.</span>

<span class="sd">    Notes:</span>
<span class="sd">        To eliminate Pulay stress, the default ENCUT is set to a rather large</span>
<span class="sd">        value of ENCUT, which is 1.5 * ENMAX.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span>
            <span class="bp">self</span><span class="p">,</span>
            <span class="n">structure</span><span class="p">,</span>
            <span class="n">start_temp</span><span class="p">,</span>
            <span class="n">end_temp</span><span class="p">,</span>
            <span class="n">nsteps</span><span class="p">,</span>
            <span class="n">time_step</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span>
            <span class="n">spin_polarized</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
            <span class="o">**</span><span class="n">kwargs</span>
    <span class="p">):</span>
        <span class="sa">r</span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            structure (Structure): input structure.</span>
<span class="sd">            start_temp (int): Starting temperature.</span>
<span class="sd">            end_temp (int): Final temperature.</span>
<span class="sd">            nsteps(int): Number of time steps for simulations. NSW parameter.</span>
<span class="sd">            time_step (int): The time step for the simulation. The POTIM</span>
<span class="sd">                parameter. Defaults to 2fs.</span>
<span class="sd">            spin_polarized (bool): Whether to do spin polarized calculations.</span>
<span class="sd">                The ISPIN parameter. Defaults to False.</span>
<span class="sd">            **kwargs: Other kwargs supported by :class:`DictSet`.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">user_incar_settings</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;user_incar_settings&quot;</span><span class="p">,</span> <span class="p">{})</span>

        <span class="c1"># NPT-AIMD default settings</span>
        <span class="n">defaults</span> <span class="o">=</span> <span class="p">{</span>
            <span class="s2">&quot;IALGO&quot;</span><span class="p">:</span> <span class="mi">48</span><span class="p">,</span>
            <span class="s2">&quot;ISIF&quot;</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
            <span class="s2">&quot;LANGEVIN_GAMMA&quot;</span><span class="p">:</span> <span class="p">[</span><span class="mi">10</span><span class="p">]</span> <span class="o">*</span> <span class="n">structure</span><span class="o">.</span><span class="n">ntypesp</span><span class="p">,</span>
            <span class="s2">&quot;LANGEVIN_GAMMA_L&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
            <span class="s2">&quot;MDALGO&quot;</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
            <span class="s2">&quot;PMASS&quot;</span><span class="p">:</span> <span class="mi">10</span><span class="p">,</span>
            <span class="s2">&quot;PSTRESS&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
            <span class="s2">&quot;SMASS&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
        <span class="p">}</span>

        <span class="n">defaults</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">user_incar_settings</span><span class="p">)</span>
        <span class="n">kwargs</span><span class="p">[</span><span class="s2">&quot;user_incar_settings&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">defaults</span>

        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span>
            <span class="n">structure</span><span class="p">,</span> <span class="n">start_temp</span><span class="p">,</span> <span class="n">end_temp</span><span class="p">,</span> <span class="n">nsteps</span><span class="p">,</span> <span class="n">time_step</span><span class="p">,</span> <span class="n">spin_polarized</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span>
        <span class="p">)</span>

        <span class="c1"># Set NPT-AIMD ENCUT = 1.5 * VASP_default</span>
        <span class="n">enmax</span> <span class="o">=</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">potcar</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">keywords</span><span class="p">[</span><span class="s2">&quot;ENMAX&quot;</span><span class="p">]</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">structure</span><span class="o">.</span><span class="n">ntypesp</span><span class="p">)]</span>
        <span class="n">encut</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="n">enmax</span><span class="p">)</span> <span class="o">*</span> <span class="mf">1.5</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_config_dict</span><span class="p">[</span><span class="s2">&quot;INCAR&quot;</span><span class="p">][</span><span class="s2">&quot;ENCUT&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">encut</span></div>


<div class="viewcode-block" id="MVLScanRelaxSet"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.MVLScanRelaxSet">[docs]</a><span class="k">class</span> <span class="nc">MVLScanRelaxSet</span><span class="p">(</span><span class="n">MPRelaxSet</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Class for writing a relax input set using Strongly Constrained and</span>
<span class="sd">    Appropriately Normed (SCAN) semilocal density functional.</span>

<span class="sd">    Notes:</span>
<span class="sd">        1. This functional is only available from VASP.5.4.3 upwards.</span>

<span class="sd">        2. Meta-GGA calculations require POTCAR files that include</span>
<span class="sd">        information on the kinetic energy density of the core-electrons,</span>
<span class="sd">        i.e. &quot;PBE_52&quot; or &quot;PBE_54&quot;. Make sure the POTCAR including the</span>
<span class="sd">        following lines (see VASP wiki for more details):</span>

<span class="sd">            $ grep kinetic POTCAR</span>
<span class="sd">            kinetic energy-density</span>
<span class="sd">            mkinetic energy-density pseudized</span>
<span class="sd">            kinetic energy density (partial)</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">structure</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sa">r</span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            structure (Structure): input structure.</span>
<span class="sd">            vdw (str): set &quot;rVV10&quot; to enable SCAN+rVV10, which is a versatile</span>
<span class="sd">                van der Waals density functional by combing the SCAN functional</span>
<span class="sd">                with the rVV10 non-local correlation functional.</span>
<span class="sd">            **kwargs: Other kwargs supported by :class:`DictSet`.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="c1"># choose PBE_52 unless the user specifies something else</span>
        <span class="k">if</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;potcar_functional&quot;</span><span class="p">)</span> <span class="ow">or</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;user_potcar_functional&quot;</span><span class="p">):</span>
            <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">structure</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">structure</span><span class="p">,</span> <span class="n">user_potcar_functional</span><span class="o">=</span><span class="s2">&quot;PBE_52&quot;</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">potcar_functional</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;PBE_52&quot;</span><span class="p">,</span> <span class="s2">&quot;PBE_54&quot;</span><span class="p">]:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;SCAN calculations required PBE_52 or PBE_54!&quot;</span><span class="p">)</span>

        <span class="n">updates</span> <span class="o">=</span> <span class="p">{</span>
            <span class="s2">&quot;ADDGRID&quot;</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span>
            <span class="s2">&quot;EDIFF&quot;</span><span class="p">:</span> <span class="mf">1e-05</span><span class="p">,</span>
            <span class="s2">&quot;EDIFFG&quot;</span><span class="p">:</span> <span class="o">-</span><span class="mf">0.05</span><span class="p">,</span>
            <span class="s2">&quot;LASPH&quot;</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span>
            <span class="s2">&quot;LDAU&quot;</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span>
            <span class="s2">&quot;METAGGA&quot;</span><span class="p">:</span> <span class="s2">&quot;SCAN&quot;</span><span class="p">,</span>
            <span class="s2">&quot;NELM&quot;</span><span class="p">:</span> <span class="mi">200</span><span class="p">,</span>
        <span class="p">}</span>

        <span class="k">if</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;vdw&quot;</span><span class="p">,</span> <span class="s2">&quot;&quot;</span><span class="p">)</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;rvv10&quot;</span><span class="p">:</span>
            <span class="n">updates</span><span class="p">[</span><span class="s2">&quot;BPARAM&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="mf">15.7</span>  <span class="c1"># This is the correct BPARAM for SCAN+rVV10</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">_config_dict</span><span class="p">[</span><span class="s2">&quot;INCAR&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">updates</span><span class="p">)</span></div>


<div class="viewcode-block" id="LobsterSet"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.LobsterSet">[docs]</a><span class="k">class</span> <span class="nc">LobsterSet</span><span class="p">(</span><span class="n">MPRelaxSet</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Input set to prepare VASP runs that can be digested by Lobster (See cohp.de)</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="n">CONFIG</span> <span class="o">=</span> <span class="n">_load_yaml_config</span><span class="p">(</span><span class="s2">&quot;MPRelaxSet&quot;</span><span class="p">)</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span>
            <span class="bp">self</span><span class="p">,</span>
            <span class="n">structure</span><span class="p">:</span> <span class="n">Structure</span><span class="p">,</span>
            <span class="n">isym</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span>
            <span class="n">ismear</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="o">-</span><span class="mi">5</span><span class="p">,</span>
            <span class="n">reciprocal_density</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
            <span class="n">address_basis_file</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
            <span class="n">user_supplied_basis</span><span class="p">:</span> <span class="nb">dict</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
            <span class="o">**</span><span class="n">kwargs</span>
    <span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            structure (Structure): input structure.</span>
<span class="sd">            isym (int): ISYM entry for INCAR, only isym=-1 and isym=0 are allowed</span>
<span class="sd">            ismear (int): ISMEAR entry for INCAR, only ismear=-5 and ismear=0 are allowed</span>
<span class="sd">            reciprocal_density (int): density of k-mesh by reciprocal volume</span>
<span class="sd">            user_supplied_basis (dict): dict including basis functions for all elements in structure,</span>
<span class="sd">                e.g. {&quot;Fe&quot;: &quot;3d 3p 4s&quot;, &quot;O&quot;: &quot;2s 2p&quot;}; if not supplied, a standard basis is used</span>
<span class="sd">            address_basis_file (str): address to a file similar to &quot;BASIS_PBE_54_standaard.yaml&quot; </span>
<span class="sd">                in pymatgen.io.lobster.lobster_basis</span>
<span class="sd">            **kwargs: Other kwargs supported by :class:`DictSet`.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span>
            <span class="s2">&quot;Make sure that all parameters are okay! This is a brand new implementation.&quot;</span>
        <span class="p">)</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="p">(</span><span class="n">isym</span> <span class="o">==</span> <span class="o">-</span><span class="mi">1</span> <span class="ow">or</span> <span class="n">isym</span> <span class="o">==</span> <span class="mi">0</span><span class="p">):</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;Lobster cannot digest WAVEFUNCTIONS with symmetry&quot;</span><span class="p">)</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="p">(</span><span class="n">ismear</span> <span class="o">==</span> <span class="o">-</span><span class="mi">5</span> <span class="ow">or</span> <span class="n">ismear</span> <span class="o">==</span> <span class="mi">0</span><span class="p">):</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;Lobster usually works with ismear=-5 or ismear=0&quot;</span><span class="p">)</span>

        <span class="c1"># newest potcars are preferred</span>
        <span class="c1"># Choose PBE_54 unless the user specifies a different potcar_functional</span>
        <span class="k">if</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;potcar_functional&quot;</span><span class="p">)</span> <span class="ow">or</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;user_potcar_functional&quot;</span><span class="p">):</span>
            <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">structure</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">structure</span><span class="p">,</span> <span class="n">user_potcar_functional</span><span class="o">=</span><span class="s2">&quot;PBE_54&quot;</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>

        <span class="c1"># reciprocal density</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">user_kpoints_settings</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="k">if</span> <span class="p">(</span>
                    <span class="ow">not</span> <span class="n">reciprocal_density</span>
                    <span class="ow">or</span> <span class="s2">&quot;reciprocal_density&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">user_kpoints_settings</span>
            <span class="p">):</span>
                <span class="c1"># test, if this is okay</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">reciprocal_density</span> <span class="o">=</span> <span class="mi">310</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">reciprocal_density</span> <span class="o">=</span> <span class="p">(</span>
                        <span class="n">reciprocal_density</span>
                        <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">user_kpoints_settings</span><span class="p">[</span><span class="s2">&quot;reciprocal_density&quot;</span><span class="p">]</span>
                <span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="n">reciprocal_density</span><span class="p">:</span>
                <span class="c1"># test, if this is okay</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">reciprocal_density</span> <span class="o">=</span> <span class="mi">310</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">reciprocal_density</span> <span class="o">=</span> <span class="n">reciprocal_density</span>

        <span class="c1"># might need to be adapted in the future</span>
        <span class="n">ediff_per_atom</span> <span class="o">=</span> <span class="mf">5e-05</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">isym</span> <span class="o">=</span> <span class="n">isym</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">ismear</span> <span class="o">=</span> <span class="n">ismear</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">user_supplied_basis</span> <span class="o">=</span> <span class="n">user_supplied_basis</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">address_basis_file</span> <span class="o">=</span> <span class="n">address_basis_file</span>
        <span class="c1"># predefined basis! Check if the basis is okay! (charge spilling and bandoverlaps!)</span>
        <span class="k">if</span> <span class="n">user_supplied_basis</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">and</span> <span class="n">address_basis_file</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">basis</span> <span class="o">=</span> <span class="n">Lobsterin</span><span class="o">.</span><span class="n">get_basis</span><span class="p">(</span>
                <span class="n">structure</span><span class="o">=</span><span class="n">structure</span><span class="p">,</span> <span class="n">potcar_symbols</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">potcar_symbols</span>
            <span class="p">)</span>
        <span class="k">elif</span> <span class="n">address_basis_file</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">basis</span> <span class="o">=</span> <span class="n">Lobsterin</span><span class="o">.</span><span class="n">get_basis</span><span class="p">(</span>
                <span class="n">structure</span><span class="o">=</span><span class="n">structure</span><span class="p">,</span>
                <span class="n">potcar_symbols</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">potcar_symbols</span><span class="p">,</span>
                <span class="n">address_basis_file</span><span class="o">=</span><span class="n">address_basis_file</span><span class="p">,</span>
            <span class="p">)</span>
        <span class="k">elif</span> <span class="n">user_supplied_basis</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="c1"># test if all elements from structure are in user_supplied_basis</span>
            <span class="k">for</span> <span class="n">atomtype</span> <span class="ow">in</span> <span class="n">structure</span><span class="o">.</span><span class="n">symbol_set</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">atomtype</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">user_supplied_basis</span><span class="p">:</span>
                    <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                        <span class="s2">&quot;There are no basis functions for the atom type &quot;</span>
                        <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">atomtype</span><span class="p">)</span>
                    <span class="p">)</span>
            <span class="n">basis</span> <span class="o">=</span> <span class="p">[</span><span class="n">key</span> <span class="o">+</span> <span class="s2">&quot; &quot;</span> <span class="o">+</span> <span class="n">value</span> <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">user_supplied_basis</span><span class="o">.</span><span class="n">items</span><span class="p">()]</span>

        <span class="n">lobsterin</span> <span class="o">=</span> <span class="n">Lobsterin</span><span class="p">(</span><span class="n">settingsdict</span><span class="o">=</span><span class="p">{</span><span class="s2">&quot;basisfunctions&quot;</span><span class="p">:</span> <span class="n">basis</span><span class="p">})</span>
        <span class="n">nbands</span> <span class="o">=</span> <span class="n">lobsterin</span><span class="o">.</span><span class="n">_get_nbands</span><span class="p">(</span><span class="n">structure</span><span class="o">=</span><span class="n">structure</span><span class="p">)</span>

        <span class="n">update_dict</span> <span class="o">=</span> <span class="p">{</span>
            <span class="s2">&quot;EDIFF_PER_ATOM&quot;</span><span class="p">:</span> <span class="n">ediff_per_atom</span><span class="p">,</span>
            <span class="s2">&quot;NSW&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
            <span class="s2">&quot;LWAVE&quot;</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span>
            <span class="s2">&quot;ISYM&quot;</span><span class="p">:</span> <span class="n">isym</span><span class="p">,</span>
            <span class="s2">&quot;NBANDS&quot;</span><span class="p">:</span> <span class="n">nbands</span><span class="p">,</span>
            <span class="s2">&quot;IBRION&quot;</span><span class="p">:</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span>
            <span class="s2">&quot;ISMEAR&quot;</span><span class="p">:</span> <span class="n">ismear</span><span class="p">,</span>
            <span class="s2">&quot;LORBIT&quot;</span><span class="p">:</span> <span class="mi">11</span><span class="p">,</span>
            <span class="s2">&quot;ICHARG&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
            <span class="s2">&quot;ALGO&quot;</span><span class="p">:</span> <span class="s2">&quot;Normal&quot;</span><span class="p">,</span>
        <span class="p">}</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">_config_dict</span><span class="p">[</span><span class="s2">&quot;INCAR&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">update_dict</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_config_dict</span><span class="p">[</span><span class="s2">&quot;KPOINTS&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">update</span><span class="p">(</span>
            <span class="p">{</span><span class="s2">&quot;reciprocal_density&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">reciprocal_density</span><span class="p">}</span>
        <span class="p">)</span></div>


<div class="viewcode-block" id="get_vasprun_outcar"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.get_vasprun_outcar">[docs]</a><span class="k">def</span> <span class="nf">get_vasprun_outcar</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">parse_dos</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">parse_eigen</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    :param path: Path to get the vasprun.xml and OUTCAR.</span>
<span class="sd">    :param parse_dos: Whether to parse dos. Defaults to True.</span>
<span class="sd">    :param parse_eigen: Whether to parse eigenvalue. Defaults to True.</span>
<span class="sd">    :return:</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">path</span> <span class="o">=</span> <span class="n">Path</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
    <span class="n">vruns</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">glob</span><span class="o">.</span><span class="n">glob</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">path</span> <span class="o">/</span> <span class="s2">&quot;vasprun.xml*&quot;</span><span class="p">)))</span>
    <span class="n">outcars</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">glob</span><span class="o">.</span><span class="n">glob</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">path</span> <span class="o">/</span> <span class="s2">&quot;OUTCAR*&quot;</span><span class="p">)))</span>

    <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">vruns</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">or</span> <span class="nb">len</span><span class="p">(</span><span class="n">outcars</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
        <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
            <span class="s2">&quot;Unable to get vasprun.xml/OUTCAR from prev calculation in </span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="n">path</span>
        <span class="p">)</span>
    <span class="n">vsfile_fullpath</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">path</span> <span class="o">/</span> <span class="s2">&quot;vasprun.xml&quot;</span><span class="p">)</span>
    <span class="n">outcarfile_fullpath</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">path</span> <span class="o">/</span> <span class="s2">&quot;OUTCAR&quot;</span><span class="p">)</span>
    <span class="n">vsfile</span> <span class="o">=</span> <span class="n">vsfile_fullpath</span> <span class="k">if</span> <span class="n">vsfile_fullpath</span> <span class="ow">in</span> <span class="n">vruns</span> <span class="k">else</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">vruns</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
    <span class="n">outcarfile</span> <span class="o">=</span> <span class="p">(</span>
        <span class="n">outcarfile_fullpath</span> <span class="k">if</span> <span class="n">outcarfile_fullpath</span> <span class="ow">in</span> <span class="n">outcars</span> <span class="k">else</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">outcars</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
    <span class="p">)</span>
    <span class="k">return</span> <span class="p">(</span>
        <span class="n">Vasprun</span><span class="p">(</span><span class="n">vsfile</span><span class="p">,</span> <span class="n">parse_dos</span><span class="o">=</span><span class="n">parse_dos</span><span class="p">,</span> <span class="n">parse_eigen</span><span class="o">=</span><span class="n">parse_eigen</span><span class="p">),</span>
        <span class="n">Outcar</span><span class="p">(</span><span class="n">outcarfile</span><span class="p">),</span>
    <span class="p">)</span></div>


<div class="viewcode-block" id="get_structure_from_prev_run"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.get_structure_from_prev_run">[docs]</a><span class="k">def</span> <span class="nf">get_structure_from_prev_run</span><span class="p">(</span><span class="n">vasprun</span><span class="p">,</span> <span class="n">outcar</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Process structure from previous run.</span>

<span class="sd">    Args:</span>
<span class="sd">        vasprun (Vasprun): Vasprun that contains the final structure</span>
<span class="sd">            from previous run.</span>
<span class="sd">        outcar (Outcar): Outcar that contains the magnetization info from</span>
<span class="sd">            previous run.</span>

<span class="sd">    Returns:</span>
<span class="sd">        Returns the magmom-decorated structure that can be passed to get</span>
<span class="sd">        Vasp input files, e.g. get_kpoints.</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">structure</span> <span class="o">=</span> <span class="n">vasprun</span><span class="o">.</span><span class="n">final_structure</span>

    <span class="n">site_properties</span> <span class="o">=</span> <span class="p">{}</span>
    <span class="c1"># magmom</span>
    <span class="k">if</span> <span class="n">vasprun</span><span class="o">.</span><span class="n">is_spin</span><span class="p">:</span>
        <span class="k">if</span> <span class="n">outcar</span> <span class="ow">and</span> <span class="n">outcar</span><span class="o">.</span><span class="n">magnetization</span><span class="p">:</span>
            <span class="n">site_properties</span><span class="o">.</span><span class="n">update</span><span class="p">({</span><span class="s2">&quot;magmom&quot;</span><span class="p">:</span> <span class="p">[</span><span class="n">i</span><span class="p">[</span><span class="s2">&quot;tot&quot;</span><span class="p">]</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">outcar</span><span class="o">.</span><span class="n">magnetization</span><span class="p">]})</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">site_properties</span><span class="o">.</span><span class="n">update</span><span class="p">({</span><span class="s2">&quot;magmom&quot;</span><span class="p">:</span> <span class="n">vasprun</span><span class="o">.</span><span class="n">parameters</span><span class="p">[</span><span class="s2">&quot;MAGMOM&quot;</span><span class="p">]})</span>
    <span class="c1"># ldau</span>
    <span class="k">if</span> <span class="n">vasprun</span><span class="o">.</span><span class="n">parameters</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;LDAU&quot;</span><span class="p">,</span> <span class="kc">False</span><span class="p">):</span>
        <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">&quot;LDAUU&quot;</span><span class="p">,</span> <span class="s2">&quot;LDAUJ&quot;</span><span class="p">,</span> <span class="s2">&quot;LDAUL&quot;</span><span class="p">):</span>
            <span class="n">vals</span> <span class="o">=</span> <span class="n">vasprun</span><span class="o">.</span><span class="n">incar</span><span class="p">[</span><span class="n">k</span><span class="p">]</span>
            <span class="n">m</span> <span class="o">=</span> <span class="p">{}</span>
            <span class="n">l_val</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="n">s</span> <span class="o">=</span> <span class="mi">0</span>
            <span class="k">for</span> <span class="n">site</span> <span class="ow">in</span> <span class="n">structure</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">site</span><span class="o">.</span><span class="n">specie</span><span class="o">.</span><span class="n">symbol</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">m</span><span class="p">:</span>
                    <span class="n">m</span><span class="p">[</span><span class="n">site</span><span class="o">.</span><span class="n">specie</span><span class="o">.</span><span class="n">symbol</span><span class="p">]</span> <span class="o">=</span> <span class="n">vals</span><span class="p">[</span><span class="n">s</span><span class="p">]</span>
                    <span class="n">s</span> <span class="o">+=</span> <span class="mi">1</span>
                <span class="n">l_val</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">m</span><span class="p">[</span><span class="n">site</span><span class="o">.</span><span class="n">specie</span><span class="o">.</span><span class="n">symbol</span><span class="p">])</span>
            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">l_val</span><span class="p">)</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span><span class="n">structure</span><span class="p">):</span>
                <span class="n">site_properties</span><span class="o">.</span><span class="n">update</span><span class="p">({</span><span class="n">k</span><span class="o">.</span><span class="n">lower</span><span class="p">():</span> <span class="n">l_val</span><span class="p">})</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                    <span class="s2">&quot;length of list </span><span class="si">{}</span><span class="s2"> not the same as&quot;</span> <span class="s2">&quot;structure&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">l_val</span><span class="p">)</span>
                <span class="p">)</span>

    <span class="k">return</span> <span class="n">structure</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">site_properties</span><span class="o">=</span><span class="n">site_properties</span><span class="p">)</span></div>


<div class="viewcode-block" id="standardize_structure"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.standardize_structure">[docs]</a><span class="k">def</span> <span class="nf">standardize_structure</span><span class="p">(</span><span class="n">structure</span><span class="p">,</span> <span class="n">sym_prec</span><span class="o">=</span><span class="mf">0.1</span><span class="p">,</span> <span class="n">international_monoclinic</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Get the symmetrically standardized structure.</span>

<span class="sd">    Args:</span>
<span class="sd">        structure (Structure): The structure.</span>
<span class="sd">        sym_prec (float): Tolerance for symmetry finding for standardization.</span>
<span class="sd">        international_monoclinic (bool): Whether to use international</span>
<span class="sd">            convention (vs Curtarolo) for monoclinic. Defaults True.</span>

<span class="sd">    Returns:</span>
<span class="sd">        The symmetrized structure.</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">sym_finder</span> <span class="o">=</span> <span class="n">SpacegroupAnalyzer</span><span class="p">(</span><span class="n">structure</span><span class="p">,</span> <span class="n">symprec</span><span class="o">=</span><span class="n">sym_prec</span><span class="p">)</span>
    <span class="n">new_structure</span> <span class="o">=</span> <span class="n">sym_finder</span><span class="o">.</span><span class="n">get_primitive_standard_structure</span><span class="p">(</span>
        <span class="n">international_monoclinic</span><span class="o">=</span><span class="n">international_monoclinic</span>
    <span class="p">)</span>

    <span class="c1"># the primitive structure finding has had several bugs in the past</span>
    <span class="c1"># defend through validation</span>
    <span class="n">vpa_old</span> <span class="o">=</span> <span class="n">structure</span><span class="o">.</span><span class="n">volume</span> <span class="o">/</span> <span class="n">structure</span><span class="o">.</span><span class="n">num_sites</span>
    <span class="n">vpa_new</span> <span class="o">=</span> <span class="n">new_structure</span><span class="o">.</span><span class="n">volume</span> <span class="o">/</span> <span class="n">new_structure</span><span class="o">.</span><span class="n">num_sites</span>

    <span class="k">if</span> <span class="nb">abs</span><span class="p">(</span><span class="n">vpa_old</span> <span class="o">-</span> <span class="n">vpa_new</span><span class="p">)</span> <span class="o">/</span> <span class="n">vpa_old</span> <span class="o">&gt;</span> <span class="mf">0.02</span><span class="p">:</span>
        <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
            <span class="s2">&quot;Standardizing cell failed! VPA old: </span><span class="si">{}</span><span class="s2">, VPA new: </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                <span class="n">vpa_old</span><span class="p">,</span> <span class="n">vpa_new</span>
            <span class="p">)</span>
        <span class="p">)</span>

    <span class="n">sm</span> <span class="o">=</span> <span class="n">StructureMatcher</span><span class="p">()</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="n">sm</span><span class="o">.</span><span class="n">fit</span><span class="p">(</span><span class="n">structure</span><span class="p">,</span> <span class="n">new_structure</span><span class="p">):</span>
        <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;Standardizing cell failed! Old structure doesn&#39;t match new.&quot;</span><span class="p">)</span>

    <span class="k">return</span> <span class="n">new_structure</span></div>


<div class="viewcode-block" id="BadInputSetWarning"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.BadInputSetWarning">[docs]</a><span class="k">class</span> <span class="nc">BadInputSetWarning</span><span class="p">(</span><span class="ne">UserWarning</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Warning class for bad but legal inputs.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">pass</span></div>


<div class="viewcode-block" id="batch_write_input"><a class="viewcode-back" href="../../../../pymatgen.io.vasp.sets.html#pymatgen.io.vasp.sets.batch_write_input">[docs]</a><span class="k">def</span> <span class="nf">batch_write_input</span><span class="p">(</span>
        <span class="n">structures</span><span class="p">,</span>
        <span class="n">vasp_input_set</span><span class="o">=</span><span class="n">MPRelaxSet</span><span class="p">,</span>
        <span class="n">output_dir</span><span class="o">=</span><span class="s2">&quot;.&quot;</span><span class="p">,</span>
        <span class="n">make_dir_if_not_present</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
        <span class="n">subfolder</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
        <span class="n">sanitize</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
        <span class="n">include_cif</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
        <span class="n">potcar_spec</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
        <span class="n">zip_output</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
        <span class="o">**</span><span class="n">kwargs</span>
<span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Batch write vasp input for a sequence of structures to</span>
<span class="sd">    output_dir, following the format output_dir/{group}/{formula}_{number}.</span>

<span class="sd">    Args:</span>
<span class="sd">        structures ([Structure]): Sequence of Structures.</span>
<span class="sd">        vasp_input_set (VaspInputSet): VaspInputSet class that creates</span>
<span class="sd">            vasp input files from structures. Note that a class should be</span>
<span class="sd">            supplied. Defaults to MPRelaxSet.</span>
<span class="sd">        output_dir (str): Directory to output files. Defaults to current</span>
<span class="sd">            directory &quot;.&quot;.</span>
<span class="sd">        make_dir_if_not_present (bool): Create the directory if not present.</span>
<span class="sd">            Defaults to True.</span>
<span class="sd">        subfolder (callable): Function to create subdirectory name from</span>
<span class="sd">            structure. Defaults to simply &quot;formula_count&quot;.</span>
<span class="sd">        sanitize (bool): Boolean indicating whether to sanitize the</span>
<span class="sd">            structure before writing the VASP input files. Sanitized output</span>
<span class="sd">            are generally easier for viewing and certain forms of analysis.</span>
<span class="sd">            Defaults to False.</span>
<span class="sd">        include_cif (bool): Whether to output a CIF as well. CIF files are</span>
<span class="sd">            generally better supported in visualization programs.</span>
<span class="sd">        potcar_spec (bool): Instead of writing the POTCAR, write a &quot;POTCAR.spec&quot;.</span>
<span class="sd">                This is intended to help sharing an input set with people who might</span>
<span class="sd">                not have a license to specific Potcar files. Given a &quot;POTCAR.spec&quot;,</span>
<span class="sd">                the specific POTCAR file can be re-generated using pymatgen with the</span>
<span class="sd">                &quot;generate_potcar&quot; function in the pymatgen CLI.</span>
<span class="sd">        zip_output (bool): If True, output will be zipped into a file with the</span>
<span class="sd">            same name as the InputSet (e.g., MPStaticSet.zip)</span>
<span class="sd">        **kwargs: Additional kwargs are passed to the vasp_input_set class</span>
<span class="sd">            in addition to structure.</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">output_dir</span> <span class="o">=</span> <span class="n">Path</span><span class="p">(</span><span class="n">output_dir</span><span class="p">)</span>
    <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">s</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">structures</span><span class="p">):</span>
        <span class="n">formula</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">sub</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;\s+&quot;</span><span class="p">,</span> <span class="s2">&quot;&quot;</span><span class="p">,</span> <span class="n">s</span><span class="o">.</span><span class="n">formula</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">subfolder</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">subdir</span> <span class="o">=</span> <span class="n">subfolder</span><span class="p">(</span><span class="n">s</span><span class="p">)</span>
            <span class="n">d</span> <span class="o">=</span> <span class="n">output_dir</span> <span class="o">/</span> <span class="n">subdir</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">d</span> <span class="o">=</span> <span class="n">output_dir</span> <span class="o">/</span> <span class="s2">&quot;</span><span class="si">{}</span><span class="s2">_</span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">formula</span><span class="p">,</span> <span class="n">i</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">sanitize</span><span class="p">:</span>
            <span class="n">s</span> <span class="o">=</span> <span class="n">s</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">sanitize</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
        <span class="n">v</span> <span class="o">=</span> <span class="n">vasp_input_set</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
        <span class="n">v</span><span class="o">.</span><span class="n">write_input</span><span class="p">(</span>
            <span class="nb">str</span><span class="p">(</span><span class="n">d</span><span class="p">),</span>
            <span class="n">make_dir_if_not_present</span><span class="o">=</span><span class="n">make_dir_if_not_present</span><span class="p">,</span>
            <span class="n">include_cif</span><span class="o">=</span><span class="n">include_cif</span><span class="p">,</span>
            <span class="n">potcar_spec</span><span class="o">=</span><span class="n">potcar_spec</span><span class="p">,</span>
            <span class="n">zip_output</span><span class="o">=</span><span class="n">zip_output</span><span class="p">,</span>
        <span class="p">)</span></div>


<span class="n">_dummy_structure</span> <span class="o">=</span> <span class="n">Structure</span><span class="p">(</span>
    <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">],</span>
    <span class="p">[</span><span class="s2">&quot;I&quot;</span><span class="p">],</span>
    <span class="p">[[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">]],</span>
    <span class="n">site_properties</span><span class="o">=</span><span class="p">{</span><span class="s2">&quot;magmom&quot;</span><span class="p">:</span> <span class="p">[[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">]]},</span>
<span class="p">)</span>
</pre></div>

            <div class="clearer"></div>
          </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../../../index.html">pymatgen 2020.7.3 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../../../index.html" >Module code</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="../../../pymatgen.html" >pymatgen</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">pymatgen.io.vasp.sets</a></li> 
      </ul>
    </div>

    <div class="footer" role="contentinfo">
        &#169; Copyright 2011, Pymatgen Development Team.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.1.2.
    </div>
<div class="footer">This page uses <a href="http://analytics.google.com/">
Google Analytics</a> to collect statistics. You can disable it by blocking
the JavaScript coming from www.google-analytics.com.
<script type="text/javascript">
  (function() {
    var ga = document.createElement('script');
    ga.src = ('https:' == document.location.protocol ?
              'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    ga.setAttribute('async', 'true');
    document.documentElement.firstChild.appendChild(ga);
  })();
</script>
</div>

  </body>
</html>